Compare commits
No commits in common. "master" and "khorben/mimehandler" have entirely different histories.
master
...
khorben/mi
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,5 @@ Makefile
|
||||
*.o
|
||||
*.so
|
||||
*.so.*
|
||||
/config.ent
|
||||
/config.h
|
||||
/config.sh
|
||||
|
4
COPYING
4
COPYING
@ -9,6 +9,10 @@ met:
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the authors nor the names of the contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
|
75
README.md
75
README.md
@ -1,75 +0,0 @@
|
||||
DeforaOS Browser
|
||||
================
|
||||
|
||||
About Browser
|
||||
-------------
|
||||
|
||||
Browser is a file manager and image browser.
|
||||
|
||||
It can be extended through plug-ins, which are then displayed in the left pane
|
||||
of the file management windows.
|
||||
|
||||
Browser is part of the DeforaOS Project, found at https://www.defora.org/.
|
||||
|
||||
|
||||
Compiling Browser
|
||||
-----------------
|
||||
|
||||
Browser depends on the following components:
|
||||
|
||||
* Gtk+ 2.4 or newer, or Gtk+ 3.0 or newer
|
||||
* DeforaOS libDesktop
|
||||
* an implementation of `make`
|
||||
* gettext (libintl) for translations
|
||||
* DocBook-XSL for the manual pages
|
||||
* GTK-Doc for the API documentation
|
||||
|
||||
With these installed, the following command should be enough to compile and
|
||||
install Browser on most systems:
|
||||
|
||||
$ make install
|
||||
|
||||
To install (or package) Browser in a different location, use the `PREFIX` option
|
||||
as follows:
|
||||
|
||||
$ make PREFIX="/another/prefix" install
|
||||
|
||||
Browser also supports `DESTDIR`, to be installed in a staging directory; for
|
||||
instance:
|
||||
|
||||
$ make DESTDIR="/staging/directory" PREFIX="/another/prefix" install
|
||||
|
||||
The compilation process supports a number of other options, such as OBJDIR for
|
||||
compilation outside of the source tree for instance.
|
||||
|
||||
On some systems, the Makefiles shipped may have to be re-generated accordingly.
|
||||
This can be performed with the DeforaOS configure tool.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Manual pages for each of the executables installed are available in the `doc`
|
||||
folder. They are written in the DocBook-XML format, and need libxslt and
|
||||
DocBook-XSL to be installed for conversion to the HTML or man file format.
|
||||
|
||||
Likewise, the API reference for Browser (plug-ins) is available in the
|
||||
`doc/gtkdoc` folder, and is generated using gtk-doc.
|
||||
|
||||
Extending Browser
|
||||
-----------------
|
||||
|
||||
Plug-ins for the Browser program can be written according to the API definitions
|
||||
installed and found in `<Desktop/Browser.h>` (in the source code in the
|
||||
`include/Browser.h` file).
|
||||
|
||||
A sample plug-in can be found in `src/plugins/template.c`.
|
||||
|
||||
Further plug-ins may also be found in the
|
||||
[DeforaOS Integration](https://www.defora.org/os/project/4339/Integration)
|
||||
project.
|
||||
|
||||
Distributing Browser
|
||||
--------------------
|
||||
|
||||
DeforaOS Browser is subject to the terms of the 2-clause BSD license. Please
|
||||
see the `COPYING` file for more information.
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Name=File manager
|
||||
Comment=File manager and image browser
|
||||
Comment=File manager and image viewer
|
||||
TryExec=browser
|
||||
Exec=browser
|
||||
Icon=system-file-manager
|
@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Name=Open folder
|
||||
Comment=Open folder in file manager
|
||||
TryExec=browser
|
||||
Exec=browser %F
|
||||
Icon=inode-directory
|
||||
Type=Application
|
||||
NoDisplay=true
|
||||
MimeTypes=inode/directory;
|
||||
Categories=System;Core;FileManager;GTK;
|
||||
StartupNotify=true
|
@ -1,10 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Name=File viewer
|
||||
Comment=Viewer for text and image files
|
||||
TryExec=view
|
||||
Exec=view %F
|
||||
Icon=system-file-manager
|
||||
Type=Application
|
||||
Categories=System;Core;FileManager;GTK;
|
||||
StartupNotify=true
|
||||
Hidden=true
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2011-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -25,116 +25,19 @@
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/pkgconfig.sh}/../config.sh"
|
||||
PREFIX="/usr/local"
|
||||
[ -f "../config.sh" ] && . "../config.sh"
|
||||
DEBUG="_debug"
|
||||
DEVNULL="/dev/null"
|
||||
PROGNAME="pkgconfig.sh"
|
||||
#executables
|
||||
DEBUG="_debug"
|
||||
INSTALL="install"
|
||||
INSTALL="install -m 0644"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
SED="sed"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#pkgconfig
|
||||
_pkgconfig()
|
||||
{
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
return $?
|
||||
fi
|
||||
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
|
||||
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
|
||||
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
|
||||
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
|
||||
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
|
||||
if [ -z "$SYSCONFDIR" ]; then
|
||||
SYSCONFDIR="$PREFIX/etc"
|
||||
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
|
||||
fi
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || return 2
|
||||
mode="-m 0644"
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL $mode "$target" "$PKGCONFIG/$basename" \
|
||||
|| return 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
"Darwin")
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
"SunOS")
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|
||||
|| return 2
|
||||
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
|
||||
-e "s;@PACKAGE@;$PACKAGE;g" \
|
||||
-e "s;@VERSION@;$VERSION;g" \
|
||||
-e "s;@PREFIX@;$PREFIX;g" \
|
||||
-e "s;@BINDIR@;$BINDIR;g" \
|
||||
-e "s;@DATADIR@;$DATADIR;g" \
|
||||
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
|
||||
-e "s;@LIBDIR@;$LIBDIR;g" \
|
||||
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
|
||||
-e "s;@MANDIR@;$MANDIR;g" \
|
||||
-e "s;@PWD@;$PWD;g" \
|
||||
-e "s;@RPATH@;$RPATH;g" \
|
||||
-e "s;@SBINDIR@;$SBINDIR;g" \
|
||||
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$RM -- "$target" 2> "$DEVNULL"
|
||||
return 2
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
@ -163,7 +66,7 @@ _usage()
|
||||
clean=0
|
||||
install=0
|
||||
uninstall=0
|
||||
while getopts "ciuO:P:" name; do
|
||||
while getopts "ciuP:" name; do
|
||||
case $name in
|
||||
c)
|
||||
clean=1
|
||||
@ -176,9 +79,6 @@ while getopts "ciuO:P:" name; do
|
||||
install=0
|
||||
uninstall=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
P)
|
||||
PREFIX="$OPTARG"
|
||||
;;
|
||||
@ -189,10 +89,72 @@ while getopts "ciuO:P:" name; do
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -eq 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
_error "The VERSION variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
PKGCONFIG="$PREFIX/lib/pkgconfig"
|
||||
exec 3>&1
|
||||
_pkgconfig "$@"
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$PKGCONFIG/$target" || exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
source="${target#$OBJDIR}"
|
||||
$DEBUG $MKDIR -- "$PKGCONFIG" || exit 2
|
||||
basename="$source"
|
||||
if [ "${source##*/}" != "$source" ]; then
|
||||
basename="${source##*/}"
|
||||
fi
|
||||
$DEBUG $INSTALL "$target" "$PKGCONFIG/$basename"|| exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#portability
|
||||
RPATH=
|
||||
if [ "$PREFIX" != "/usr" ]; then
|
||||
RPATH="-Wl,-rpath-link,\${libdir} -Wl,-rpath,\${libdir}"
|
||||
case $(uname -s) in
|
||||
Darwin)
|
||||
RPATH="-Wl,-rpath,\${libdir}"
|
||||
;;
|
||||
SunOS)
|
||||
RPATH="-Wl,-R\${libdir}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#create
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source}.in"
|
||||
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;" \
|
||||
-e "s;@VERSION@;$VERSION;" \
|
||||
-e "s;@PREFIX@;$PREFIX;" \
|
||||
-e "s;@RPATH@;$RPATH;" \
|
||||
-- "$source" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$DEBUG $RM -- "$target"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
@ -1,23 +1,15 @@
|
||||
subdirs=16x16
|
||||
targets=Browser.pc
|
||||
dist=Makefile,Browser.pc.in,org.defora.browser.desktop,org.defora.browser-folder.desktop,org.defora.view.desktop,org.defora.desktop-settings.desktop,pkgconfig.sh
|
||||
dist=Makefile,Browser.pc.in,deforaos-browser.desktop,deforaos-desktop-settings.desktop,pkgconfig.sh
|
||||
|
||||
#targets
|
||||
[Browser.pc]
|
||||
type=script
|
||||
script=./pkgconfig.sh
|
||||
depends=Browser.pc.in,../config.sh
|
||||
install=
|
||||
|
||||
#dist
|
||||
[org.defora.browser.desktop]
|
||||
[deforaos-browser.desktop]
|
||||
install=$(PREFIX)/share/applications
|
||||
|
||||
[org.defora.browser-folder.desktop]
|
||||
install=$(PREFIX)/share/applications
|
||||
|
||||
[org.defora.desktop-settings.desktop]
|
||||
install=$(PREFIX)/share/applications
|
||||
|
||||
[org.defora.view.desktop]
|
||||
[deforaos-desktop-settings.desktop]
|
||||
install=$(PREFIX)/share/applications
|
||||
|
7
doc/.gitignore
vendored
7
doc/.gitignore
vendored
@ -13,22 +13,15 @@
|
||||
/desktopctl.1
|
||||
/desktopctl.html
|
||||
/desktopctl.xml
|
||||
/gtkdoc/html
|
||||
/gtkdoc/html.stamp
|
||||
/gtkdoc/Browser.types
|
||||
/gtkdoc/tmpl.stamp
|
||||
/gtkdoc/xml.stamp
|
||||
/move.1
|
||||
/move.html
|
||||
/move.xml
|
||||
/open.1
|
||||
/open.html
|
||||
/open.xml
|
||||
/pinentry-sudo-askpass
|
||||
/properties.1
|
||||
/properties.html
|
||||
/properties.xml
|
||||
/view.1
|
||||
/view.html
|
||||
/view.xml
|
||||
/zenity-sudo-askpass
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -25,22 +25,17 @@
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/docbook.sh}/../config.sh"
|
||||
PREFIX="/usr/local"
|
||||
[ -f "../config.sh" ] && . "../config.sh"
|
||||
PROGNAME="docbook.sh"
|
||||
XSL_HTML="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
|
||||
XSL_MAN="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
|
||||
XSL_PDF="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
|
||||
#executables
|
||||
DEBUG="_debug"
|
||||
FOP="fop"
|
||||
INSTALL="install -m 0644"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
XMLLINT="xmllint --noent --nonet --xinclude --path ${PWD}"
|
||||
XSLTPROC="xsltproc --nonet --xinclude --path ${PWD}"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
XMLLINT="xmllint"
|
||||
XSLTPROC="xsltproc --nonet --xinclude"
|
||||
|
||||
|
||||
#functions
|
||||
@ -63,20 +58,18 @@ _docbook()
|
||||
ext="${ext##.}"
|
||||
case "$ext" in
|
||||
html)
|
||||
XSL="$XSL_HTML"
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
|
||||
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
|
||||
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
|
||||
if [ -f "${target%.*}.css.xml" ]; then
|
||||
XSLTPROC_PARAMS="--param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
|
||||
XSLTPROC="$XSLTPROC --param custom.css.source \"${target%.*}.css.xml\" --param generate.css.header 1"
|
||||
elif [ -f "${source%.*}.css.xml" ]; then
|
||||
XSLTPROC_PARAMS="--param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
|
||||
else
|
||||
XSLTPROC_PARAMS=
|
||||
XSLTPROC="$XSLTPROC --param custom.css.source \"${source%.*}.css.xml\" --param generate.css.header 1"
|
||||
fi
|
||||
$DEBUG $XSLTPROC $XSLTPROC_PARAMS -o "$target" "$XSL" "$source"
|
||||
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
|
||||
;;
|
||||
pdf)
|
||||
XSL="$XSL_PDF"
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"
|
||||
[ -f "${source%.*}.xsl" ] && XSL="${source%.*}.xsl"
|
||||
[ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl"
|
||||
$DEBUG $XSLTPROC -o "${target%.*}.fo" "$XSL" "$source" &&
|
||||
@ -84,7 +77,7 @@ _docbook()
|
||||
$RM -- "${target%.*}.fo"
|
||||
;;
|
||||
1|2|3|4|5|6|7|8|9)
|
||||
XSL="$XSL_MAN"
|
||||
XSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
|
||||
$DEBUG $XSLTPROC -o "$target" "$XSL" "$source"
|
||||
;;
|
||||
*)
|
||||
@ -121,7 +114,7 @@ _usage()
|
||||
clean=0
|
||||
install=0
|
||||
uninstall=0
|
||||
while getopts "ciO:uP:" name; do
|
||||
while getopts "ciuP:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
@ -130,9 +123,6 @@ while getopts "ciO:uP:" name; do
|
||||
uninstall=0
|
||||
install=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
u)
|
||||
install=0
|
||||
uninstall=1
|
||||
@ -147,7 +137,7 @@ while getopts "ciO:uP:" name; do
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -eq 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
@ -175,9 +165,9 @@ while [ $# -gt 0 ]; do
|
||||
source="${target#$OBJDIR}"
|
||||
source="${source%.*}.xml"
|
||||
xpath="string(/refentry/refmeta/manvolnum)"
|
||||
section=$($DEBUG $XMLLINT --xpath "$xpath" "$source")
|
||||
section=$($XMLLINT --xpath "$xpath" "$source")
|
||||
if [ $? -eq 0 -a -n "$section" ]; then
|
||||
instdir="$MANDIR/html$section"
|
||||
instdir="$DATADIR/man/html$section"
|
||||
fi
|
||||
;;
|
||||
pdf)
|
||||
|
290
doc/gtkdoc.sh
290
doc/gtkdoc.sh
@ -1,290 +0,0 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/gtkdoc.sh}/../config.sh"
|
||||
PREFIX="/usr/local"
|
||||
PROGNAME="gtkdoc.sh"
|
||||
#executables
|
||||
CP="cp"
|
||||
DEBUG="_debug"
|
||||
GTKDOC_FIXXREF="gtkdoc-fixxref"
|
||||
GTKDOC_MKDB="gtkdoc-mkdb"
|
||||
GTKDOC_MKHTML="gtkdoc-mkhtml"
|
||||
GTKDOC_MKTMPL="gtkdoc-mktmpl"
|
||||
GTKDOC_SCAN="gtkdoc-scan"
|
||||
INSTALL="install -m 0644"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
RMDIR="rmdir"
|
||||
TOUCH="touch"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
echo "$@" 1>&3
|
||||
"$@"
|
||||
}
|
||||
|
||||
|
||||
#error
|
||||
_error()
|
||||
{
|
||||
echo "$PROGNAME: $@" 1>&2
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
#gtkdoc_fixxref
|
||||
_gtkdoc_fixxref()
|
||||
{
|
||||
module="$1"
|
||||
moduledir="$2"
|
||||
htmldir="$3"
|
||||
outputdir="$4"
|
||||
|
||||
(cd "$outputdir" &&
|
||||
$DEBUG $GTKDOC_FIXXREF \
|
||||
--module="$module" \
|
||||
--module-dir="$moduledir" \
|
||||
--html-dir="$htmldir") || exit 2
|
||||
}
|
||||
|
||||
|
||||
#gtkdoc_mkdb
|
||||
_gtkdoc_mkdb()
|
||||
{
|
||||
module="$1"
|
||||
sourcedir="$2"
|
||||
outputdir="$3"
|
||||
|
||||
(cd "$sourcedir" &&
|
||||
$DEBUG $GTKDOC_MKDB --module="$module" \
|
||||
--output-dir="$outputdir" \
|
||||
--output-format="xml" --tmpl-dir="tmpl")
|
||||
}
|
||||
|
||||
|
||||
#gtkdoc_mkhtml
|
||||
_gtkdoc_mkhtml()
|
||||
{
|
||||
module="$1"
|
||||
path="$2"
|
||||
driver="$3"
|
||||
outputdir="$4"
|
||||
|
||||
(cd "$outputdir" &&
|
||||
$DEBUG $GTKDOC_MKHTML --path "$path" "$module" "$driver")
|
||||
}
|
||||
|
||||
|
||||
#gtkdoc_mktmpl
|
||||
_gtkdoc_mktmpl()
|
||||
{
|
||||
module="$1"
|
||||
sourcedir="$2"
|
||||
outputdir="$3"
|
||||
|
||||
(cd "$sourcedir" &&
|
||||
$DEBUG $GTKDOC_MKTMPL --module="$module" \
|
||||
--output-dir="$outputdir")
|
||||
}
|
||||
|
||||
|
||||
#gtkdoc_scan
|
||||
_gtkdoc_scan()
|
||||
{
|
||||
module="$1"
|
||||
sourcedir="$2"
|
||||
outputdir="$3"
|
||||
|
||||
(cd ".." &&
|
||||
$DEBUG $GTKDOC_SCAN --module="$module" \
|
||||
--source-dir="$sourcedir" \
|
||||
--output-dir="$outputdir")
|
||||
# --rebuild-types
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: $PROGNAME [-c|-i|-u][-P prefix] target..." 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
clean=0
|
||||
install=0
|
||||
uninstall=0
|
||||
while getopts "ciO:uP:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
;;
|
||||
i)
|
||||
uninstall=0
|
||||
install=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
u)
|
||||
install=0
|
||||
uninstall=1
|
||||
;;
|
||||
P)
|
||||
PREFIX="$OPTARG"
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#check the variables
|
||||
if [ -z "$PACKAGE" ]; then
|
||||
_error "The PACKAGE variable needs to be set"
|
||||
exit $?
|
||||
fi
|
||||
MODULE="$PACKAGE"
|
||||
|
||||
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
|
||||
instdir="$DATADIR/gtk-doc/html"
|
||||
|
||||
exec 3>&1
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
target="${target#$OBJDIR}"
|
||||
shift
|
||||
|
||||
#clean
|
||||
[ "$clean" -ne 0 ] && continue
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
for i in "${OBJDIR}gtkdoc/html/"*.*; do
|
||||
[ -f "$i" ] || continue
|
||||
file="${i##*/}"
|
||||
$DEBUG $RM -- "$instdir/$MODULE/$file" || exit 2
|
||||
done
|
||||
if [ -d "$instdir/$MODULE" ]; then
|
||||
$DEBUG $RMDIR -- "$instdir/$MODULE" || exit 2
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
#create
|
||||
case "$target" in
|
||||
gtkdoc/html.stamp)
|
||||
output="${OBJDIR}gtkdoc/html"
|
||||
$DEBUG $MKDIR -- "$output" || exit 2
|
||||
driver="$MODULE-docs.xml"
|
||||
oldpath="$PWD"
|
||||
[ -n "$OBJDIR" ] && for file in \
|
||||
"gtkdoc/$driver" \
|
||||
"gtkdoc/xml/gtkdocentities.ent"; do
|
||||
[ -f "$file" ] || continue
|
||||
$DEBUG $CP -- "$file" \
|
||||
"${OBJDIR}$file" || exit 2
|
||||
done
|
||||
_gtkdoc_mkhtml "$MODULE" "${oldpath%/*}" "../$driver" \
|
||||
"$output"
|
||||
#detect when gtk-doc is not available
|
||||
res=$?
|
||||
if [ $res -eq 127 ]; then
|
||||
_error "$GTKDOC_MKHTML: Not available" \
|
||||
"(not generating documentation)"
|
||||
continue
|
||||
elif [ $res -ne 0 ]; then
|
||||
exit 2
|
||||
fi
|
||||
output="${OBJDIR}gtkdoc"
|
||||
_gtkdoc_fixxref "$MODULE" "html" "$instdir" "$output"
|
||||
;;
|
||||
gtkdoc/tmpl.stamp)
|
||||
output="tmpl"
|
||||
if [ -n "$OBJDIR" ]; then
|
||||
output="${OBJDIR}gtkdoc/tmpl"
|
||||
$DEBUG $MKDIR -- "$output" || exit 2
|
||||
fi
|
||||
_gtkdoc_mktmpl "$MODULE" "${OBJDIR}gtkdoc" "$output"
|
||||
;;
|
||||
gtkdoc/xml.stamp)
|
||||
output="xml"
|
||||
if [ -n "$OBJDIR" ]; then
|
||||
output="${OBJDIR}gtkdoc"
|
||||
sections="gtkdoc/$MODULE-sections.txt"
|
||||
$DEBUG $MKDIR -- "$output/xml" || exit 2
|
||||
$DEBUG $CP -- "$sections" "$output" \
|
||||
|| exit 2
|
||||
_gtkdoc_scan "$MODULE" "include" "$output"
|
||||
output="${OBJDIR}gtkdoc/xml"
|
||||
fi
|
||||
_gtkdoc_mkdb "$MODULE" "${OBJDIR}gtkdoc" "$output"
|
||||
;;
|
||||
gtkdoc/*.types)
|
||||
output="$PWD/gtkdoc" || exit 2
|
||||
if [ -n "$OBJDIR" ]; then
|
||||
output="${OBJDIR}gtkdoc"
|
||||
$DEBUG $MKDIR -- "$output" || exit 2
|
||||
fi
|
||||
_gtkdoc_scan "$MODULE" "include" "$output"
|
||||
;;
|
||||
*)
|
||||
_error "$target: Unknown type"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
#XXX ignore errors
|
||||
if [ $? -ne 0 ]; then
|
||||
_error "$target: Could not create documentation"
|
||||
install=0
|
||||
fi
|
||||
$TOUCH "${OBJDIR}$target"
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
$DEBUG $MKDIR "$instdir/$MODULE" || exit 2
|
||||
for i in "${OBJDIR}gtkdoc/html/"*.*; do
|
||||
[ -f "$i" ] || continue
|
||||
file="${i##*/}"
|
||||
$DEBUG $INSTALL "$i" "$instdir/$MODULE/$file" \
|
||||
|| exit 2
|
||||
done
|
||||
fi
|
||||
done
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||
[
|
||||
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
|
||||
%gtkdocentities;
|
||||
<!ENTITY % configentities SYSTEM "config.ent">
|
||||
%configentities;
|
||||
]>
|
||||
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||
<bookinfo>
|
||||
<title>&vendor; &package; &title;</title>
|
||||
<releaseinfo>
|
||||
for &vendor; &package; &version;.
|
||||
The latest version of this documentation can be found on-line at
|
||||
<ulink role="online-location" url="https://&server;/&package;/">https://&server;/&package;/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<chapter>
|
||||
<title>&vendor; &package;</title>
|
||||
<xi:include href="xml/desktop.xml"/>
|
||||
<xi:include href="xml/plugin.xml"/>
|
||||
<xi:include href="xml/vfs.xml"/>
|
||||
</chapter>
|
||||
<!-- enable this when you use gobject types
|
||||
<chapter id="object-tree">
|
||||
<title>Object Hierarchy</title>
|
||||
<xi:include href="xml/tree_index.sgml"/>
|
||||
</chapter>
|
||||
-->
|
||||
<index id="api-index-full">
|
||||
<title>API Index</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<index id="deprecated-api-index" role="deprecated">
|
||||
<title>Index of deprecated API</title>
|
||||
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<!-- enable this when you use gobject introspection annotations
|
||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||
-->
|
||||
</book>
|
@ -1,55 +0,0 @@
|
||||
<SECTION>
|
||||
<FILE>Browser</FILE>
|
||||
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>desktop</FILE>
|
||||
DesktopAlignment
|
||||
DesktopIcons
|
||||
DESKTOP_ICONS_LAST
|
||||
DESKTOP_ICONS_COUNT
|
||||
DesktopLayout
|
||||
DesktopMessage
|
||||
DesktopMessageShow
|
||||
DESKTOP_CLIENT_MESSAGE
|
||||
Desktop
|
||||
DesktopHandler
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>plugin</FILE>
|
||||
config_get
|
||||
config_set
|
||||
error
|
||||
get_icon
|
||||
get_mime
|
||||
get_type
|
||||
refresh
|
||||
set_location
|
||||
init
|
||||
destroy
|
||||
get_widget
|
||||
Browser
|
||||
BrowserPlugin
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>vfs</FILE>
|
||||
browser_vfs_can_eject
|
||||
browser_vfs_can_mount
|
||||
browser_vfs_can_unmount
|
||||
browser_vfs_is_mountpoint
|
||||
browser_vfs_mkdir
|
||||
browser_vfs_opendir
|
||||
browser_vfs_closedir
|
||||
browser_vfs_readdir
|
||||
browser_vfs_eject
|
||||
browser_vfs_mount
|
||||
browser_vfs_unmount
|
||||
browser_vfs_mime_icon
|
||||
browser_vfs_mime_type
|
||||
browser_vfs_lstat
|
||||
browser_vfs_stat
|
||||
</SECTION>
|
||||
|
@ -1 +0,0 @@
|
||||
dist=Makefile,Browser-docs.xml,Browser-sections.txt,xml/gtkdocentities.ent
|
@ -1,2 +0,0 @@
|
||||
<!ENTITY server "www.defora.org/doc/gtk-doc/html">
|
||||
<!ENTITY title "Reference Manual">
|
@ -60,17 +60,11 @@
|
||||
<arg choice="opt"><option>-a</option> <replaceable>action</replaceable></arg>
|
||||
<arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
<cmdsynopsis>
|
||||
<command>&name;</command>
|
||||
<arg choice="plain"><option>-t</option></arg>
|
||||
<arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
<refsect1 id="description">
|
||||
<title>Description</title>
|
||||
<para><command>&name;</command> automatically chooses the registered handler
|
||||
to open one or more files from the command line interface. To do so, it
|
||||
attempts to guess the MIME type of each file listed.</para>
|
||||
to open one or more files from the command line interface.</para>
|
||||
</refsect1>
|
||||
<refsect1 id="options">
|
||||
<title>Options</title>
|
||||
@ -89,12 +83,6 @@
|
||||
type according to the respective file extension.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-t</option></term>
|
||||
<listitem>
|
||||
<para>Detect the type of the files listed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1 id="bugs">
|
||||
|
@ -1,40 +0,0 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2018 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Desktop Browser
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
#met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Redistributions in binary form must reproduce the above copyright notice
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
#DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
#DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
#THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ret=2
|
||||
echo "SETTITLE sudo password prompt
|
||||
SETDESC Your password is needed to perform this operation.
|
||||
SETPROMPT Password:
|
||||
GETPIN
|
||||
BYE" | @BINDIR@/pinentry-gtk-2 | while read key values; do
|
||||
case "$key" in
|
||||
D)
|
||||
echo "$values"
|
||||
ret=0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
exit $ret
|
@ -1,190 +1,155 @@
|
||||
subdirs=gtkdoc
|
||||
targets=browser.1,browser.html,browser.xml,copy.1,copy.html,copy.xml,delete.1,delete.html,delete.xml,desktop.1,desktop.html,desktop.xml,desktopctl.1,desktopctl.html,desktopctl.xml,gtkdoc/Browser.types,gtkdoc/html.stamp,gtkdoc/tmpl.stamp,gtkdoc/xml.stamp,move.1,move.html,move.xml,open.1,open.html,open.xml,pinentry-sudo-askpass,properties.1,properties.html,properties.xml,view.1,view.html,view.xml,zenity-sudo-askpass
|
||||
dist=Makefile,browser.css.xml,browser.xml.in,copy.css.xml,copy.xml.in,delete.css.xml,delete.xml.in,desktop.css.xml,desktop.xml.in,desktopctl.css.xml,desktopctl.xml.in,docbook.sh,gtkdoc.sh,manual.css.xml,mime.conf,move.css.xml,move.xml.in,open.css.xml,open.xml.in,pinentry-sudo-askpass.in,properties.css.xml,properties.xml.in,view.css.xml,view.xml.in,zenity-sudo-askpass.in
|
||||
targets=browser.1,browser.html,browser.xml,copy.1,copy.html,copy.xml,delete.1,delete.html,delete.xml,desktop.1,desktop.html,desktop.xml,desktopctl.1,desktopctl.html,desktopctl.xml,move.1,move.html,move.xml,open.1,open.html,open.xml,properties.1,properties.html,properties.xml,view.1,view.html,view.xml
|
||||
dist=Makefile,browser.css.xml,browser.xml.in,copy.css.xml,copy.xml.in,delete.css.xml,delete.xml.in,desktop.css.xml,desktop.xml.in,desktopctl.css.xml,desktopctl.xml.in,docbook.sh,manual.css.xml,mime.conf,move.css.xml,move.xml.in,open.css.xml,open.xml.in,properties.css.xml,properties.xml.in,view.css.xml,view.xml.in
|
||||
|
||||
#targets
|
||||
[browser.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)browser.xml
|
||||
install=
|
||||
depends=$(OBJDIR)browser.xml
|
||||
|
||||
[browser.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=browser.css.xml,docbook.sh,$(OBJDIR)browser.xml,manual.css.xml
|
||||
install=
|
||||
depends=browser.css.xml,$(OBJDIR)browser.xml,manual.css.xml
|
||||
|
||||
[browser.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,browser.xml.in,../config.sh
|
||||
depends=browser.xml.in
|
||||
|
||||
[copy.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)copy.xml
|
||||
install=
|
||||
depends=$(OBJDIR)copy.xml
|
||||
|
||||
[copy.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=copy.css.xml,docbook.sh,$(OBJDIR)copy.xml,manual.css.xml
|
||||
install=
|
||||
depends=copy.css.xml,$(OBJDIR)copy.xml,manual.css.xml
|
||||
|
||||
[copy.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,copy.xml.in,../config.sh
|
||||
depends=copy.xml.in
|
||||
|
||||
[delete.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)delete.xml
|
||||
install=
|
||||
depends=$(OBJDIR)delete.xml
|
||||
|
||||
[delete.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=delete.css.xml,docbook.sh,$(OBJDIR)delete.xml,manual.css.xml
|
||||
install=
|
||||
depends=delete.css.xml,$(OBJDIR)delete.xml,manual.css.xml
|
||||
|
||||
[delete.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,delete.xml.in,../config.sh
|
||||
depends=delete.xml.in
|
||||
|
||||
[desktop.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)desktop.xml
|
||||
install=
|
||||
depends=$(OBJDIR)desktop.xml
|
||||
|
||||
[desktop.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=desktop.css.xml,docbook.sh,$(OBJDIR)desktop.xml,manual.css.xml
|
||||
install=
|
||||
depends=desktop.css.xml,$(OBJDIR)desktop.xml,manual.css.xml
|
||||
|
||||
[desktop.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,desktop.xml.in,../config.sh
|
||||
depends=desktop.xml.in
|
||||
|
||||
[desktopctl.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)desktopctl.xml
|
||||
install=
|
||||
depends=$(OBJDIR)desktopctl.xml
|
||||
|
||||
[desktopctl.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=desktopctl.css.xml,docbook.sh,$(OBJDIR)desktopctl.xml,manual.css.xml
|
||||
install=
|
||||
depends=desktopctl.css.xml,$(OBJDIR)desktopctl.xml,manual.css.xml
|
||||
|
||||
[desktopctl.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,desktopctl.xml.in,../config.sh
|
||||
|
||||
[gtkdoc/Browser.types]
|
||||
type=script
|
||||
script=./gtkdoc.sh
|
||||
depends=gtkdoc.sh,../config.sh
|
||||
|
||||
[gtkdoc/html.stamp]
|
||||
type=script
|
||||
script=./gtkdoc.sh
|
||||
depends=gtkdoc.sh,gtkdoc/Browser-docs.xml,$(OBJDIR)gtkdoc/xml.stamp,gtkdoc/xml/gtkdocentities.ent,../config.ent
|
||||
install=
|
||||
|
||||
[gtkdoc/tmpl.stamp]
|
||||
type=script
|
||||
script=./gtkdoc.sh
|
||||
depends=gtkdoc.sh,$(OBJDIR)gtkdoc/Browser.types
|
||||
|
||||
[gtkdoc/xml.stamp]
|
||||
type=script
|
||||
script=./gtkdoc.sh
|
||||
depends=gtkdoc.sh,$(OBJDIR)gtkdoc/tmpl.stamp
|
||||
depends=desktopctl.xml.in
|
||||
|
||||
[move.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)move.xml
|
||||
install=
|
||||
depends=$(OBJDIR)move.xml
|
||||
|
||||
[move.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,manual.css.xml,move.css.xml,$(OBJDIR)move.xml
|
||||
install=
|
||||
depends=manual.css.xml,move.css.xml,$(OBJDIR)move.xml
|
||||
|
||||
[move.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,move.xml.in,../config.sh
|
||||
depends=move.xml.in
|
||||
|
||||
[open.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)open.xml
|
||||
install=
|
||||
depends=$(OBJDIR)open.xml
|
||||
|
||||
[open.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,manual.css.xml,open.css.xml,$(OBJDIR)open.xml
|
||||
install=
|
||||
depends=manual.css.xml,open.css.xml,$(OBJDIR)open.xml
|
||||
|
||||
[open.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,open.xml.in,../config.sh
|
||||
|
||||
[pinentry-sudo-askpass]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,pinentry-sudo-askpass.in,../config.sh
|
||||
install=$(PREFIX)/share/doc/Browser
|
||||
depends=open.xml.in
|
||||
|
||||
[properties.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)properties.xml
|
||||
install=
|
||||
depends=$(OBJDIR)properties.xml
|
||||
|
||||
[properties.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,manual.css.xml,properties.css.xml,$(OBJDIR)properties.xml
|
||||
install=
|
||||
depends=manual.css.xml,properties.css.xml,$(OBJDIR)properties.xml
|
||||
|
||||
[properties.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,properties.xml.in,../config.sh
|
||||
depends=properties.xml.in
|
||||
|
||||
[view.1]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,$(OBJDIR)view.xml
|
||||
install=
|
||||
depends=$(OBJDIR)view.xml
|
||||
|
||||
[view.html]
|
||||
type=script
|
||||
script=./docbook.sh
|
||||
depends=docbook.sh,manual.css.xml,view.css.xml,$(OBJDIR)view.xml
|
||||
install=
|
||||
depends=manual.css.xml,view.css.xml,$(OBJDIR)view.xml
|
||||
|
||||
[view.xml]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,view.xml.in,../config.sh
|
||||
|
||||
[zenity-sudo-askpass]
|
||||
type=script
|
||||
script=../tools/subst.sh
|
||||
depends=../tools/subst.sh,zenity-sudo-askpass.in,../config.sh
|
||||
install=$(PREFIX)/share/doc/Browser
|
||||
depends=view.xml.in
|
||||
|
@ -1,27 +0,0 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2018 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Desktop Browser
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
#met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Redistributions in binary form must reproduce the above copyright notice
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
#DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
#DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
#THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@BINDIR@/zenity --password --title="sudo password prompt"
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -27,7 +31,6 @@
|
||||
#ifndef DESKTOP_BROWSER_H
|
||||
# define DESKTOP_BROWSER_H
|
||||
|
||||
# include "Browser/browser.h"
|
||||
# include "Browser/desktop.h"
|
||||
# include "Browser/plugin.h"
|
||||
# include "Browser/vfs.h"
|
||||
|
@ -1,54 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#ifndef BROWSER_BROWSER_BROWSER_H
|
||||
# define BROWSER_BROWSER_BROWSER_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
|
||||
|
||||
/* Browser */
|
||||
/* public */
|
||||
/* types */
|
||||
typedef enum _BrowserView
|
||||
{
|
||||
BROWSER_VIEW_DETAILS = 0,
|
||||
# if GTK_CHECK_VERSION(2, 6, 0)
|
||||
BROWSER_VIEW_ICONS,
|
||||
BROWSER_VIEW_LIST,
|
||||
BROWSER_VIEW_THUMBNAILS
|
||||
# endif
|
||||
} BrowserView;
|
||||
# define BROWSER_VIEW_FIRST BROWSER_VIEW_DETAILS
|
||||
# if GTK_CHECK_VERSION(2, 6, 0)
|
||||
# define BROWSER_VIEW_LAST BROWSER_VIEW_DETAILS
|
||||
# else
|
||||
# define BROWSER_VIEW_LAST BROWSER_VIEW_THUMBNAILS
|
||||
# endif
|
||||
# define BROWSER_VIEW_COUNT (BROWSER_VIEW_LAST + 1)
|
||||
|
||||
#endif /* !BROWSER_BROWSER_BROWSER_H */
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -35,21 +39,12 @@
|
||||
/* Desktop */
|
||||
/* public */
|
||||
/* types */
|
||||
typedef struct _Desktop Desktop;
|
||||
|
||||
typedef enum _DesktopAlignment
|
||||
{
|
||||
DESKTOP_ALIGNMENT_VERTICAL = 0,
|
||||
DESKTOP_ALIGNMENT_HORIZONTAL
|
||||
} DesktopAlignment;
|
||||
|
||||
typedef struct _DesktopHandler DesktopHandler;
|
||||
|
||||
typedef struct _DesktopHandlerHelper
|
||||
{
|
||||
Desktop * desktop;
|
||||
} DesktopHandlerHelper;
|
||||
|
||||
typedef enum _DesktopIcons
|
||||
{
|
||||
DESKTOP_ICONS_NONE = 0,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -31,7 +35,6 @@
|
||||
# include <sys/stat.h>
|
||||
# include <gtk/gtk.h>
|
||||
# include <Desktop.h>
|
||||
# include "browser.h"
|
||||
# include "vfs.h"
|
||||
|
||||
|
||||
@ -45,28 +48,19 @@ typedef struct _BrowserPlugin BrowserPlugin;
|
||||
typedef struct _BrowserPluginHelper
|
||||
{
|
||||
Browser * browser;
|
||||
|
||||
/* accessors */
|
||||
GdkPixbuf * (*get_icon)(Browser * browser, char const * filename,
|
||||
char const * type, struct stat * lst, struct stat * st,
|
||||
int size);
|
||||
int (*get_icon_size)(Browser * browser, BrowserView view);
|
||||
Mime * (*get_mime)(Browser * browser);
|
||||
char const * (*get_type)(Browser * browser, char const * filename,
|
||||
mode_t mode);
|
||||
BrowserView (*get_view)(Browser * browser);
|
||||
|
||||
int (*set_location)(Browser * browser, char const * path);
|
||||
void (*set_view)(Browser * browser, BrowserView view);
|
||||
|
||||
int (*error)(Browser * browser, char const * message, int ret);
|
||||
void (*refresh)(Browser * browser);
|
||||
|
||||
/* Config */
|
||||
char const * (*config_get)(Browser * browser, char const * section,
|
||||
char const * variable);
|
||||
int (*config_set)(Browser * browser, char const * section,
|
||||
char const * variable, char const * value);
|
||||
int (*error)(Browser * browser, char const * message, int ret);
|
||||
GdkPixbuf * (*get_icon)(Browser * browser, char const * filename,
|
||||
char const * type, struct stat * lst, struct stat * st,
|
||||
int size);
|
||||
Mime * (*get_mime)(Browser * browser);
|
||||
char const * (*get_type)(Browser * browser, char const * filename,
|
||||
mode_t mode);
|
||||
void (*refresh)(Browser * browser);
|
||||
int (*set_location)(Browser * browser, char const * path);
|
||||
} BrowserPluginHelper;
|
||||
|
||||
typedef const struct _BrowserPluginDefinition
|
||||
|
@ -1,9 +1,6 @@
|
||||
includes=browser.h,desktop.h,plugin.h,vfs.h
|
||||
includes=desktop.h,plugin.h,vfs.h
|
||||
dist=Makefile
|
||||
|
||||
[browser.h]
|
||||
install=$(INCLUDEDIR)/Desktop/Browser
|
||||
|
||||
[desktop.h]
|
||||
install=$(INCLUDEDIR)/Desktop/Browser
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -37,24 +41,14 @@
|
||||
/* public */
|
||||
/* functions */
|
||||
/* accessors */
|
||||
int browser_vfs_can_eject(char const * mountpoint);
|
||||
int browser_vfs_can_mount(char const * mountpoint);
|
||||
int browser_vfs_can_unmount(char const * mountpoint);
|
||||
|
||||
int browser_vfs_is_mountpoint(struct stat * lst, dev_t parent);
|
||||
|
||||
/* useful */
|
||||
int browser_vfs_mkdir(char const * path, mode_t mode);
|
||||
|
||||
/* DIR */
|
||||
DIR * browser_vfs_opendir(char const * filename, struct stat * st);
|
||||
int browser_vfs_closedir(DIR * dir);
|
||||
struct dirent * browser_vfs_readdir(DIR * dir);
|
||||
|
||||
int browser_vfs_eject(char const * mountpoint);
|
||||
int browser_vfs_mount(char const * mountpoint);
|
||||
int browser_vfs_unmount(char const * mountpoint);
|
||||
|
||||
/* Mime */
|
||||
GdkPixbuf * browser_vfs_mime_icon(Mime * mime, char const * filename,
|
||||
char const * type, struct stat * lst, struct stat * st,
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2010-2015 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -25,8 +25,8 @@
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/gettext.sh}/../config.sh"
|
||||
PREFIX="/usr/local"
|
||||
[ -f "../config.sh" ] && . "../config.sh"
|
||||
LOCALEDIR="$PREFIX/share/locale"
|
||||
POTFILES="POTFILES"
|
||||
PROGNAME="gettext.sh"
|
||||
@ -40,8 +40,6 @@ MSGMERGE="msgmerge"
|
||||
RM="rm -f"
|
||||
XGETTEXT="xgettext --force-po"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#debug
|
||||
@ -114,7 +112,7 @@ _gettext_pot()
|
||||
clean=0
|
||||
install=0
|
||||
uninstall=0
|
||||
while getopts "ciO:uP:" name; do
|
||||
while getopts "ciuP:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
@ -123,9 +121,6 @@ while getopts "ciO:uP:" name; do
|
||||
uninstall=0
|
||||
install=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
u)
|
||||
install=0
|
||||
uninstall=1
|
||||
@ -140,7 +135,7 @@ while getopts "ciO:uP:" name; do
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
if [ $# -eq 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
38
project.conf
38
project.conf
@ -1,36 +1,6 @@
|
||||
vendor=Desktop
|
||||
package=Browser
|
||||
version=0.6.0
|
||||
config=ent,h,sh
|
||||
version=0.5.1
|
||||
config=h,sh
|
||||
|
||||
subdirs=data,doc,include,po,src/lib,src,src/plugins,src/widget,tests,tools
|
||||
targets=tests
|
||||
dist=Makefile,COPYING,README.md,TODO,config.ent,config.h,config.sh
|
||||
|
||||
#modes
|
||||
[mode::debug]
|
||||
title=Debug
|
||||
|
||||
[mode::embedded-debug]
|
||||
title=Debug (embedded UI)
|
||||
|
||||
[mode::embedded-release]
|
||||
title=Release (embedded UI)
|
||||
|
||||
[mode::release]
|
||||
title=Release
|
||||
|
||||
#targets
|
||||
[tests]
|
||||
type=command
|
||||
command=cd tests && (if [ -n "$(OBJDIR)" ]; then $(MAKE) OBJDIR="$(OBJDIR)tests/" "$(OBJDIR)tests/clint.log" "$(OBJDIR)tests/embedded.log" "$(OBJDIR)tests/fixme.log" "$(OBJDIR)tests/tests.log" "$(OBJDIR)tests/xmllint.log"; else $(MAKE) clint.log embedded.log fixme.log tests.log xmllint.log; fi)
|
||||
depends=all
|
||||
enabled=0
|
||||
phony=1
|
||||
|
||||
#dist
|
||||
[COPYING]
|
||||
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||
|
||||
[README.md]
|
||||
install=$(PREFIX)/share/doc/$(PACKAGE)
|
||||
subdirs=data,doc,include,po,src,src/plugins,src/widget,tests,tools
|
||||
dist=Makefile,COPYING,TODO,config.h,config.sh
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2006-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2006-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -33,22 +37,34 @@
|
||||
# include <System.h>
|
||||
# include <Desktop.h>
|
||||
# include "../../include/Browser.h"
|
||||
# include "../../config.h"
|
||||
|
||||
|
||||
/* Browser */
|
||||
/* defaults */
|
||||
# define BROWSER_CONFIG_FILE "Browser.conf"
|
||||
# define BROWSER_CONFIG_VENDOR "DeforaOS/" VENDOR
|
||||
# define BROWSER_ICON_SIZE_SMALL_ICONS 24
|
||||
# define BROWSER_ICON_SIZE_ICONS 48
|
||||
# define BROWSER_ICON_SIZE_THUMBNAILS 96
|
||||
# define BROWSER_CONFIG_FILE ".browser"
|
||||
# define BROWSER_ICON_WRAP_WIDTH 96
|
||||
# define BROWSER_LIST_WRAP_WIDTH 118
|
||||
# define BROWSER_THUMBNAIL_WRAP_WIDTH 112
|
||||
|
||||
|
||||
/* types */
|
||||
typedef enum _BrowserView
|
||||
{
|
||||
BV_DETAILS = 0,
|
||||
# if GTK_CHECK_VERSION(2, 6, 0)
|
||||
BV_ICONS,
|
||||
BV_LIST,
|
||||
BV_THUMBNAILS
|
||||
} BrowserView;
|
||||
# define BV_FIRST BV_DETAILS
|
||||
# define BV_LAST BV_THUMBNAILS
|
||||
# else
|
||||
} BrowserView;
|
||||
# define BV_FIRST BV_DETAILS
|
||||
# define BV_LAST BV_DETAILS
|
||||
# endif
|
||||
# define BV_COUNT (BV_LAST + 1)
|
||||
|
||||
typedef struct _BrowserPrefs
|
||||
{
|
||||
# if GTK_CHECK_VERSION(2, 6, 0)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2006-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2006-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -35,20 +39,23 @@
|
||||
# define unmount unmount
|
||||
# endif
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#include <System.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "callbacks.h"
|
||||
#include "browser.h"
|
||||
#include "../../config.h"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "browser"
|
||||
#endif
|
||||
#define COMMON_SYMLINK
|
||||
#include "../common.c"
|
||||
|
||||
@ -143,21 +150,23 @@ void on_home(gpointer data)
|
||||
void on_new_folder(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
char const newfolder[] = N_("New folder");
|
||||
char const * newfolder = _("New folder");
|
||||
char const * location;
|
||||
String * path;
|
||||
size_t len;
|
||||
char * path;
|
||||
|
||||
if((location = browser_get_location(browser)) == NULL)
|
||||
return;
|
||||
if((path = string_new_append(location, "/", _(newfolder), NULL))
|
||||
== NULL)
|
||||
len = strlen(location) + strlen(newfolder) + 2;
|
||||
if((path = malloc(len)) == NULL)
|
||||
{
|
||||
browser_error(browser, error_get(NULL), 1);
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
return;
|
||||
}
|
||||
if(browser_vfs_mkdir(path, 0777) != 0)
|
||||
browser_error(browser, error_get(NULL), 1);
|
||||
string_delete(path);
|
||||
snprintf(path, len, "%s/%s", location, newfolder);
|
||||
if(mkdir(path, 0777) != 0)
|
||||
browser_error(browser, strerror(errno), 1);
|
||||
free(path);
|
||||
}
|
||||
|
||||
|
||||
@ -237,17 +246,17 @@ void on_view_as(gpointer data)
|
||||
view = browser_get_view(browser);
|
||||
switch(view)
|
||||
{
|
||||
case BROWSER_VIEW_DETAILS:
|
||||
browser_set_view(browser, BROWSER_VIEW_ICONS);
|
||||
case BV_DETAILS:
|
||||
browser_set_view(browser, BV_ICONS);
|
||||
break;
|
||||
case BROWSER_VIEW_LIST:
|
||||
browser_set_view(browser, BROWSER_VIEW_THUMBNAILS);
|
||||
case BV_LIST:
|
||||
browser_set_view(browser, BV_THUMBNAILS);
|
||||
break;
|
||||
case BROWSER_VIEW_ICONS:
|
||||
browser_set_view(browser, BROWSER_VIEW_LIST);
|
||||
case BV_ICONS:
|
||||
browser_set_view(browser, BV_LIST);
|
||||
break;
|
||||
case BROWSER_VIEW_THUMBNAILS:
|
||||
browser_set_view(browser, BROWSER_VIEW_DETAILS);
|
||||
case BV_THUMBNAILS:
|
||||
browser_set_view(browser, BV_DETAILS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -258,7 +267,7 @@ void on_view_details(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
|
||||
browser_set_view(browser, BROWSER_VIEW_DETAILS);
|
||||
browser_set_view(browser, BV_DETAILS);
|
||||
}
|
||||
|
||||
|
||||
@ -267,7 +276,7 @@ void on_view_icons(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
|
||||
browser_set_view(browser, BROWSER_VIEW_ICONS);
|
||||
browser_set_view(browser, BV_ICONS);
|
||||
}
|
||||
|
||||
|
||||
@ -276,7 +285,7 @@ void on_view_list(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
|
||||
browser_set_view(browser, BROWSER_VIEW_LIST);
|
||||
browser_set_view(browser, BV_LIST);
|
||||
}
|
||||
|
||||
|
||||
@ -285,7 +294,7 @@ void on_view_thumbnails(gpointer data)
|
||||
{
|
||||
Browser * browser = data;
|
||||
|
||||
browser_set_view(browser, BROWSER_VIEW_THUMBNAILS);
|
||||
browser_set_view(browser, BV_THUMBNAILS);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2006-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2006-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2006-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2006-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -124,17 +128,17 @@ int main(int argc, char * argv[])
|
||||
switch(o)
|
||||
{
|
||||
case 'D':
|
||||
view = BROWSER_VIEW_DETAILS;
|
||||
view = BV_DETAILS;
|
||||
break;
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
case 'I':
|
||||
view = BROWSER_VIEW_ICONS;
|
||||
view = BV_ICONS;
|
||||
break;
|
||||
case 'L':
|
||||
view = BROWSER_VIEW_LIST;
|
||||
view = BV_LIST;
|
||||
break;
|
||||
case 'T':
|
||||
view = BROWSER_VIEW_THUMBNAILS;
|
||||
view = BV_THUMBNAILS;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -1,31 +1,18 @@
|
||||
targets=browser
|
||||
cppflags_force=-I../../include
|
||||
#cppflags=-D EMBEDDED
|
||||
cflags_force=`pkg-config --cflags libDesktop`
|
||||
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl -L$(OBJDIR)../lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
||||
ldflags=-pie -Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile,browser.h,callbacks.h,window.h
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-I../../include -DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-I../../include -DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-I../../include -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[browser]
|
||||
type=binary
|
||||
depends=$(OBJDIR)../lib/libBrowser.a
|
||||
sources=browser.c,callbacks.c,window.c,main.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(BINDIR)
|
||||
|
||||
#sources
|
||||
[browser.c]
|
||||
depends=callbacks.h,../common.c,window.h,browser.h,../../config.h
|
||||
cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||
@ -37,4 +24,4 @@ depends=browser.h,callbacks.h,../common.c,../../config.h
|
||||
depends=browser.h,callbacks.h,window.h,../../config.h
|
||||
|
||||
[main.c]
|
||||
depends=browser.h,../../config.h
|
||||
depends=browser.h
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -28,9 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#include "browser.h"
|
||||
#include "callbacks.h"
|
||||
#include "window.h"
|
||||
#include "../../config.h"
|
||||
@ -38,8 +40,8 @@
|
||||
#define N_(string) (string)
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME_BROWSER
|
||||
# define PROGNAME_BROWSER "browser"
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "browser"
|
||||
#endif
|
||||
|
||||
|
||||
@ -153,42 +155,47 @@ static const DesktopMenu _browserwindow_menu_file[] =
|
||||
{ N_("_Open file..."), G_CALLBACK(_browserwindow_on_file_open_file),
|
||||
NULL, GDK_CONTROL_MASK, GDK_KEY_O },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("Propert_ies"), G_CALLBACK(_browserwindow_on_file_properties),
|
||||
"document-properties", GDK_MOD1_MASK, GDK_KEY_Return },
|
||||
{ N_("_Properties"), G_CALLBACK(_browserwindow_on_file_properties),
|
||||
GTK_STOCK_PROPERTIES, GDK_MOD1_MASK, GDK_KEY_Return },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Close"), G_CALLBACK(_browserwindow_on_file_close),
|
||||
"window-close", GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
GTK_STOCK_CLOSE, GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static const DesktopMenu _browserwindow_menu_edit[] =
|
||||
{
|
||||
{ N_("_Cut"), G_CALLBACK(_browserwindow_on_edit_cut), "edit-cut",
|
||||
{ N_("_Cut"), G_CALLBACK(_browserwindow_on_edit_cut), GTK_STOCK_CUT,
|
||||
GDK_CONTROL_MASK, GDK_KEY_X },
|
||||
{ N_("Cop_y"), G_CALLBACK(_browserwindow_on_edit_copy), "edit-copy",
|
||||
{ N_("Cop_y"), G_CALLBACK(_browserwindow_on_edit_copy), GTK_STOCK_COPY,
|
||||
GDK_CONTROL_MASK, GDK_KEY_C },
|
||||
{ N_("_Paste"), G_CALLBACK(_browserwindow_on_edit_paste), "edit-paste",
|
||||
GDK_CONTROL_MASK, GDK_KEY_V },
|
||||
{ N_("_Paste"), G_CALLBACK(_browserwindow_on_edit_paste),
|
||||
GTK_STOCK_PASTE, GDK_CONTROL_MASK, GDK_KEY_V },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Delete"), G_CALLBACK(_browserwindow_on_edit_delete),
|
||||
"edit-delete", 0, 0 },
|
||||
GTK_STOCK_DELETE, 0, 0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("Select _All"), G_CALLBACK(_browserwindow_on_edit_select_all),
|
||||
"edit-select-all", GDK_CONTROL_MASK, GDK_KEY_A },
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
GTK_STOCK_SELECT_ALL,
|
||||
#else
|
||||
"edit-select-all",
|
||||
#endif
|
||||
GDK_CONTROL_MASK, GDK_KEY_A },
|
||||
{ N_("_Unselect all"), G_CALLBACK(_browserwindow_on_edit_unselect_all),
|
||||
NULL, 0, 0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Preferences"), G_CALLBACK(_browserwindow_on_edit_preferences),
|
||||
"gtk-preferences", GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
GTK_STOCK_PREFERENCES, GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static const DesktopMenu _browserwindow_menu_view[] =
|
||||
{
|
||||
{ N_("_Refresh"), G_CALLBACK(_browserwindow_on_view_refresh),
|
||||
"view-refresh", GDK_CONTROL_MASK, GDK_KEY_R },
|
||||
GTK_STOCK_REFRESH, GDK_CONTROL_MASK, GDK_KEY_R },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Home"), G_CALLBACK(_browserwindow_on_view_home), "go-home",
|
||||
{ N_("_Home"), G_CALLBACK(_browserwindow_on_view_home), GTK_STOCK_HOME,
|
||||
GDK_MOD1_MASK, GDK_KEY_Home },
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
@ -208,8 +215,12 @@ static const DesktopMenu _browserwindow_menu_help[] =
|
||||
{
|
||||
{ N_("_Contents"), G_CALLBACK(_browserwindow_on_help_contents),
|
||||
"help-contents", 0, GDK_KEY_F1 },
|
||||
{ N_("_About"), G_CALLBACK(_browserwindow_on_help_about), "help-about",
|
||||
0, 0 },
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
{ N_("_About"), G_CALLBACK(_browserwindow_on_help_about),
|
||||
GTK_STOCK_ABOUT, 0, 0 },
|
||||
#else
|
||||
{ N_("_About"), G_CALLBACK(_browserwindow_on_help_about), NULL, 0, 0 },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@ -240,7 +251,7 @@ BrowserWindow * browserwindow_new(String const * directory)
|
||||
GtkWidget * tb_menubar;
|
||||
#endif
|
||||
|
||||
if((browser = object_new(sizeof(*browser))) == NULL)
|
||||
if((browser = malloc(sizeof(*browser))) == NULL)
|
||||
{
|
||||
browser_error(NULL, (directory != NULL) ? directory : ".", 1);
|
||||
return NULL;
|
||||
@ -252,9 +263,7 @@ BrowserWindow * browserwindow_new(String const * directory)
|
||||
browser->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_add_accel_group(GTK_WINDOW(browser->window), group);
|
||||
g_object_unref(group);
|
||||
gtk_window_set_default_size(GTK_WINDOW(browser->window),
|
||||
BROWSER_ICON_SIZE_ICONS * 15,
|
||||
BROWSER_ICON_SIZE_ICONS * 10);
|
||||
gtk_window_set_default_size(GTK_WINDOW(browser->window), 720, 480);
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
gtk_window_set_icon_name(GTK_WINDOW(browser->window), ICON_NAME);
|
||||
#endif
|
||||
@ -272,7 +281,11 @@ BrowserWindow * browserwindow_new(String const * directory)
|
||||
}
|
||||
|
||||
/* widgets */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
#endif
|
||||
/* menubar */
|
||||
#ifndef EMBEDDED
|
||||
tb_menubar = desktop_menubar_create(_browserwindow_menubar, browser,
|
||||
@ -292,10 +305,10 @@ BrowserWindow * browserwindow_new(String const * directory)
|
||||
/* browserwindow_delete */
|
||||
void browserwindow_delete(BrowserWindow * browser)
|
||||
{
|
||||
if(browser->browser != NULL)
|
||||
if(browser->browser != 0)
|
||||
browser_delete(browser->browser);
|
||||
gtk_widget_destroy(browser->window);
|
||||
object_delete(browser);
|
||||
free(browser);
|
||||
browser_window_cnt--;
|
||||
}
|
||||
|
||||
@ -567,7 +580,7 @@ static void _browserwindow_on_view_details(gpointer data)
|
||||
{
|
||||
BrowserWindow * browser = data;
|
||||
|
||||
browser_set_view(browser->browser, BROWSER_VIEW_DETAILS);
|
||||
browser_set_view(browser->browser, BV_DETAILS);
|
||||
}
|
||||
|
||||
|
||||
@ -576,7 +589,7 @@ static void _browserwindow_on_view_icons(gpointer data)
|
||||
{
|
||||
BrowserWindow * browser = data;
|
||||
|
||||
browser_set_view(browser->browser, BROWSER_VIEW_ICONS);
|
||||
browser_set_view(browser->browser, BV_ICONS);
|
||||
}
|
||||
|
||||
|
||||
@ -585,7 +598,7 @@ static void _browserwindow_on_view_list(gpointer data)
|
||||
{
|
||||
BrowserWindow * browser = data;
|
||||
|
||||
browser_set_view(browser->browser, BROWSER_VIEW_LIST);
|
||||
browser_set_view(browser->browser, BV_LIST);
|
||||
}
|
||||
|
||||
|
||||
@ -594,7 +607,7 @@ static void _browserwindow_on_view_thumbnails(gpointer data)
|
||||
{
|
||||
BrowserWindow * browser = data;
|
||||
|
||||
browser_set_view(browser->browser, BROWSER_VIEW_THUMBNAILS);
|
||||
browser_set_view(browser->browser, BV_THUMBNAILS);
|
||||
}
|
||||
# endif /* GTK_CHECK_VERSION(2, 6, 0) */
|
||||
|
||||
@ -614,6 +627,6 @@ static void _browserwindow_on_help_contents(gpointer data)
|
||||
{
|
||||
(void) data;
|
||||
|
||||
desktop_help_contents(PACKAGE, PROGNAME_BROWSER);
|
||||
desktop_help_contents(PACKAGE, PROGNAME);
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
32
src/common.c
32
src/common.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2008-2021 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2008-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -22,8 +26,6 @@
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* TODO:
|
||||
* - let the user browse for a destination when creating symlinks */
|
||||
|
||||
|
||||
|
||||
@ -39,6 +41,10 @@
|
||||
|
||||
|
||||
/* prototypes */
|
||||
#ifdef COMMON_CONFIG_FILENAME
|
||||
static String * _common_config_filename(String const * name);
|
||||
#endif
|
||||
|
||||
#ifdef COMMON_DND
|
||||
static int _common_drag_data_received(GdkDragContext * context,
|
||||
GtkSelectionData * seldata, char const * dest);
|
||||
@ -62,6 +68,18 @@ static int _common_symlink(GtkWidget * window, char const * cur);
|
||||
|
||||
|
||||
/* functions */
|
||||
#ifdef COMMON_CONFIG_FILENAME
|
||||
static String * _common_config_filename(String const * name)
|
||||
{
|
||||
char const * homedir;
|
||||
|
||||
if((homedir = getenv("HOME")) == NULL)
|
||||
homedir = g_get_home_dir();
|
||||
return string_new_append(homedir, "/", name, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef COMMON_DND
|
||||
/* common_drag_data_received */
|
||||
static int _common_drag_data_received(GdkDragContext * context,
|
||||
@ -240,12 +258,10 @@ static char const * _common_size(off_t size)
|
||||
unit = N_("MB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = N_("GB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = N_("TB");
|
||||
else
|
||||
{
|
||||
sz /= 1024;
|
||||
unit = N_("PB");
|
||||
unit = N_("TB");
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%.1f %s", sz, _(unit));
|
||||
return buf;
|
||||
@ -279,7 +295,11 @@ static int _common_symlink(GtkWidget * window, char const * cur)
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
||||
if(window == NULL)
|
||||
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 0);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Destination:"));
|
||||
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 4);
|
||||
widget = gtk_entry_new();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2016-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -30,6 +34,7 @@
|
||||
|
||||
|
||||
/* types */
|
||||
typedef struct _Desktop Desktop;
|
||||
typedef struct _DesktopIcon DesktopIcon;
|
||||
typedef struct _DesktopIconWindow DesktopIconWindow;
|
||||
|
||||
|
135
src/copy.c
135
src/copy.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2007-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2007-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -43,8 +47,6 @@
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <Desktop.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
@ -146,11 +148,19 @@ static int _copy(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_window_set_title(GTK_WINDOW(copy.window), _("Copy file(s)"));
|
||||
g_signal_connect(G_OBJECT(copy.window), "delete-event", G_CALLBACK(
|
||||
_copy_on_closex), NULL);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 4);
|
||||
#endif
|
||||
left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
||||
right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
||||
/* current argument */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Copying: "));
|
||||
bold = pango_font_description_new();
|
||||
pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
|
||||
@ -170,13 +180,14 @@ static int _copy(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* progress bar */
|
||||
copy.progress = gtk_progress_bar_new();
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(copy.progress), TRUE);
|
||||
#endif
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy.progress), "");
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy.progress), " ");
|
||||
gtk_box_pack_start(GTK_BOX(vbox), copy.progress, TRUE, TRUE, 0);
|
||||
/* file copy */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Filename: "));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_widget_override_font(widget, bold);
|
||||
@ -199,7 +210,11 @@ static int _copy(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(hbox), copy.flabel, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* file copy speed */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Copied: "));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_widget_override_font(widget, bold);
|
||||
@ -220,7 +235,11 @@ static int _copy(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(hbox), copy.fspeed, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* file copy remaining */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Remaining: "));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_widget_override_font(widget, bold);
|
||||
@ -242,12 +261,13 @@ static int _copy(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* file progress bar */
|
||||
copy.fprogress = gtk_progress_bar_new();
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(copy.fprogress), TRUE);
|
||||
#endif
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy.fprogress), "");
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy.fprogress), " ");
|
||||
gtk_box_pack_start(GTK_BOX(vbox), copy.fprogress, TRUE, TRUE, 0);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||
g_signal_connect_swapped(G_OBJECT(widget), "clicked", G_CALLBACK(
|
||||
_copy_on_cancel), NULL);
|
||||
@ -303,7 +323,7 @@ static gboolean _copy_idle_first(gpointer data)
|
||||
char const * filename = copy->filev[copy->filec - 1];
|
||||
struct stat st;
|
||||
|
||||
if(browser_vfs_stat(filename, &st) != 0)
|
||||
if(stat(filename, &st) != 0)
|
||||
{
|
||||
if(errno != ENOENT)
|
||||
_copy_filename_error(copy, filename, 0);
|
||||
@ -333,14 +353,10 @@ static gboolean _copy_idle_first(gpointer data)
|
||||
|
||||
/* copy_single
|
||||
* XXX TOCTOU all over the place (*stat) but seems impossible to avoid */
|
||||
static int _single_dir(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_fifo(Copy * copy, char const * dst, mode_t mode);
|
||||
static int _single_nod(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode, dev_t rdev);
|
||||
static int _single_dir(Copy * copy, char const * src, char const * dst);
|
||||
static int _single_fifo(Copy * copy, char const * dst);
|
||||
static int _single_symlink(Copy * copy, char const * src, char const * dst);
|
||||
static int _single_regular(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_regular(Copy * copy, char const * src, char const * dst);
|
||||
static int _single_p(Copy * copy, char const * dst, struct stat const * st);
|
||||
static void _single_remaining(Copy * copy, guint64 rate);
|
||||
static gboolean _single_timeout(gpointer data);
|
||||
@ -361,23 +377,20 @@ static int _copy_single(Copy * copy, char const * src, char const * dst)
|
||||
gtk_label_set_text(GTK_LABEL(copy->flabel), src);
|
||||
free(p);
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(copy->fprogress), 0.0);
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy->fprogress), "");
|
||||
if(*(copy->prefs) & PREFS_P)
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(copy->fprogress), " ");
|
||||
if(*(copy->prefs) & PREFS_P) /* don't follow symlinks */
|
||||
{
|
||||
/* do not follow symlinks */
|
||||
if(browser_vfs_lstat(src, &st) != 0 && errno == ENOENT)
|
||||
if(lstat(src, &st) != 0 && errno == ENOENT)
|
||||
return _copy_filename_error(copy, src, 1);
|
||||
}
|
||||
else if(browser_vfs_stat(src, &st) != 0 && errno == ENOENT)
|
||||
/* follow symlinks */
|
||||
else if(stat(src, &st) != 0 && errno == ENOENT) /* follow symlinks */
|
||||
return _copy_filename_error(copy, src, 1);
|
||||
if(browser_vfs_lstat(dst, &st2) == 0)
|
||||
if(lstat(dst, &st2) == 0)
|
||||
{
|
||||
if(st.st_dev == st2.st_dev && st.st_ino == st2.st_ino)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: \"%s\"%s\n", PROGNAME_COPY,
|
||||
dst, src,
|
||||
_(" is identical (not copied)"));
|
||||
dst, src, " is identical (not copied)");
|
||||
return 0;
|
||||
}
|
||||
if(*(copy->prefs) & PREFS_i
|
||||
@ -387,25 +400,18 @@ static int _copy_single(Copy * copy, char const * src, char const * dst)
|
||||
return _copy_filename_error(copy, dst, 1);
|
||||
}
|
||||
if(S_ISDIR(st.st_mode))
|
||||
ret = _single_dir(copy, src, dst, st.st_mode & 0777);
|
||||
ret = _single_dir(copy, src, dst);
|
||||
else if(S_ISFIFO(st.st_mode))
|
||||
ret = _single_fifo(copy, dst, st.st_mode & 0666);
|
||||
else if(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
|
||||
ret = _single_nod(copy, src, dst, st.st_mode, st.st_rdev);
|
||||
ret = _single_fifo(copy, dst);
|
||||
else if(S_ISLNK(st.st_mode))
|
||||
ret = _single_symlink(copy, src, dst);
|
||||
else if(S_ISREG(st.st_mode))
|
||||
else
|
||||
{
|
||||
ret = _single_regular(copy, src, dst, st.st_mode & 0777);
|
||||
ret = _single_regular(copy, src, dst);
|
||||
timeout = g_timeout_add(250, _single_timeout, copy);
|
||||
gtk_main(); /* XXX ugly */
|
||||
g_source_remove(timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return _copy_error(copy, src, 1);
|
||||
}
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
if(*(copy->prefs) & PREFS_p) /* XXX TOCTOU */
|
||||
@ -414,20 +420,17 @@ static int _copy_single(Copy * copy, char const * src, char const * dst)
|
||||
}
|
||||
|
||||
/* single_dir */
|
||||
static int _single_recurse(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_recurse(Copy * copy, char const * src, char const * dst);
|
||||
|
||||
static int _single_dir(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_dir(Copy * copy, char const * src, char const * dst)
|
||||
{
|
||||
if(*(copy->prefs) & PREFS_R)
|
||||
return _single_recurse(copy, src, dst, mode);
|
||||
return _single_recurse(copy, src, dst);
|
||||
_copy_filename_info(copy, src, _("Omitting directory"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _single_recurse(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_recurse(Copy * copy, char const * src, char const * dst)
|
||||
{
|
||||
int ret = 0;
|
||||
Copy copy2;
|
||||
@ -442,14 +445,14 @@ static int _single_recurse(Copy * copy, char const * src, char const * dst,
|
||||
|
||||
memcpy(©2, copy, sizeof(copy2));
|
||||
copy2.prefs = &prefs2;
|
||||
if(browser_vfs_mkdir(dst, mode) != 0 && errno != EEXIST)
|
||||
if(mkdir(dst, 0777) != 0 && errno != EEXIST)
|
||||
return _copy_filename_error(copy, dst, 1);
|
||||
srclen = strlen(src);
|
||||
dstlen = strlen(dst);
|
||||
if((dir = browser_vfs_opendir(src, NULL)) == NULL)
|
||||
if((dir = opendir(src)) == NULL)
|
||||
return _copy_filename_error(copy, src, 1);
|
||||
prefs2 |= (prefs2 & PREFS_H) ? PREFS_P : 0;
|
||||
while((de = browser_vfs_readdir(dir)) != NULL)
|
||||
while((de = readdir(dir)) != NULL)
|
||||
{
|
||||
if(de->d_name[0] == '.' && (de->d_name[1] == '\0'
|
||||
|| (de->d_name[1] == '.'
|
||||
@ -471,29 +474,19 @@ static int _single_recurse(Copy * copy, char const * src, char const * dst,
|
||||
sprintf(sdst, "%s/%s", dst, de->d_name);
|
||||
ret |= _copy_single(©2, ssrc, sdst);
|
||||
}
|
||||
browser_vfs_closedir(dir);
|
||||
closedir(dir);
|
||||
free(ssrc);
|
||||
free(sdst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _single_fifo(Copy * copy, char const * dst, mode_t mode)
|
||||
static int _single_fifo(Copy * copy, char const * dst)
|
||||
{
|
||||
if(mkfifo(dst, mode) != 0)
|
||||
if(mkfifo(dst, 0666) != 0) /* XXX use mode from source? */
|
||||
return _copy_filename_error(copy, dst, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _single_nod(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode, dev_t rdev)
|
||||
{
|
||||
if(mknod(dst, mode, rdev) != 0)
|
||||
return _copy_error(copy, dst, 1);
|
||||
if(unlink(src) != 0)
|
||||
_copy_error(copy, src, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _single_symlink(Copy * copy, char const * src, char const * dst)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
@ -510,8 +503,7 @@ static int _single_symlink(Copy * copy, char const * src, char const * dst)
|
||||
static gboolean _regular_idle_in(gpointer data);
|
||||
static gboolean _regular_idle_out(gpointer data);
|
||||
|
||||
static int _single_regular(Copy * copy, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_regular(Copy * copy, char const * src, char const * dst)
|
||||
{
|
||||
int ret = 0;
|
||||
int in_fd;
|
||||
@ -522,7 +514,7 @@ static int _single_regular(Copy * copy, char const * src, char const * dst,
|
||||
return _copy_error(copy, "gettimeofday", 1);
|
||||
if((in_fd = open(src, O_RDONLY)) < 0)
|
||||
return _copy_filename_error(copy, src, 1);
|
||||
if((out_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0)
|
||||
if((out_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
|
||||
{
|
||||
ret = _copy_filename_error(copy, src, 1);
|
||||
close(in_fd);
|
||||
@ -624,8 +616,6 @@ static gboolean _channel_out(Copy * copy, GIOChannel * source)
|
||||
if(g_io_channel_write_chars(source, copy->buf, copy->buf_cnt, &written,
|
||||
&error) == G_IO_STATUS_ERROR)
|
||||
return _channel_out_error(copy, source, error);
|
||||
if(fsync(g_io_channel_unix_get_fd(source)) != 0)
|
||||
_copy_error(NULL, "fsync", -errno);
|
||||
if(copy->buf_cnt == sizeof(copy->buf))
|
||||
g_idle_add(_regular_idle_in, copy); /* read again */
|
||||
copy->buf_cnt -= written;
|
||||
@ -689,19 +679,19 @@ static int _single_p(Copy * copy, char const * dst, struct stat const * st)
|
||||
{
|
||||
struct timeval tv[2];
|
||||
|
||||
if(lchown(dst, st->st_uid, st->st_gid) != 0)
|
||||
if(chown(dst, st->st_uid, st->st_gid) != 0)
|
||||
{
|
||||
_copy_filename_error(copy, dst, 0);
|
||||
if(lchmod(dst, st->st_mode & ~(S_ISUID | S_ISGID)) != 0)
|
||||
if(chmod(dst, st->st_mode & ~(S_ISUID | S_ISGID)) != 0)
|
||||
_copy_filename_error(copy, dst, 0);
|
||||
}
|
||||
else if(lchmod(dst, st->st_mode) != 0)
|
||||
else if(chmod(dst, st->st_mode) != 0)
|
||||
_copy_filename_error(copy, dst, 0);
|
||||
tv[0].tv_sec = st->st_atime;
|
||||
tv[0].tv_usec = 0;
|
||||
tv[1].tv_sec = st->st_mtime;
|
||||
tv[1].tv_usec = 0;
|
||||
if(lutimes(dst, tv) != 0)
|
||||
if(utimes(dst, tv) != 0)
|
||||
_copy_filename_error(copy, dst, 0);
|
||||
return 0;
|
||||
}
|
||||
@ -995,7 +985,8 @@ int main(int argc, char * argv[])
|
||||
prefs |= PREFS_i;
|
||||
break;
|
||||
case 'p':
|
||||
prefs |= PREFS_p;
|
||||
prefs -= prefs & PREFS_p;
|
||||
prefs |= PREFS_i;
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
|
36
src/delete.c
36
src/delete.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2007-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2007-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -35,7 +39,6 @@
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
@ -148,9 +151,17 @@ static int _delete(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_window_set_title(GTK_WINDOW(delete.window), _("Delete file(s)"));
|
||||
g_signal_connect_swapped(delete.window, "delete-event", G_CALLBACK(
|
||||
_delete_on_closex), &delete);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 4);
|
||||
#endif
|
||||
/* counter */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_image_new_from_icon_name("stock_delete",
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
|
||||
@ -163,7 +174,11 @@ static int _delete(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(hbox), delete.label, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||
/* current argument */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
delete.hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
delete.hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
hbox = delete.hbox;
|
||||
gtk_widget_set_no_show_all(hbox, TRUE);
|
||||
widget = gtk_label_new(_("File: "));
|
||||
@ -184,12 +199,13 @@ static int _delete(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* progress bar */
|
||||
delete.progress = gtk_progress_bar_new();
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(delete.progress), TRUE);
|
||||
#endif
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(delete.progress), "");
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(delete.progress), " ");
|
||||
gtk_box_pack_start(GTK_BOX(vbox), delete.progress, TRUE, TRUE, 0);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
|
||||
_delete_on_cancel), &delete);
|
||||
@ -217,7 +233,7 @@ static void _delete_on_cancel(gpointer data)
|
||||
for(i = delete->dirv_cnt; i >= 1; i--)
|
||||
{
|
||||
if(delete->dirv[i - 1]->dir != NULL)
|
||||
browser_vfs_closedir(delete->dirv[i - 1]->dir);
|
||||
closedir(delete->dirv[i - 1]->dir);
|
||||
free(delete->dirv[i - 1]->filename);
|
||||
free(delete->dirv[i - 1]);
|
||||
}
|
||||
@ -311,7 +327,7 @@ static int _idle_do_file(Delete * delete, char const * filename)
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
|
||||
#endif
|
||||
_delete_refresh(delete, filename);
|
||||
if(browser_vfs_lstat(filename, &st) != 0 && errno == ENOENT)
|
||||
if(lstat(filename, &st) != 0 && errno == ENOENT)
|
||||
{
|
||||
if(!(*(delete->prefs) & PREFS_f))
|
||||
return _delete_filename_error(delete, filename, 1);
|
||||
@ -392,7 +408,7 @@ static int _idle_do_closedir(Delete * delete)
|
||||
int ret = 0;
|
||||
DeleteDir * dd = delete->dirv[delete->dirv_cnt - 1];
|
||||
|
||||
browser_vfs_closedir(dd->dir);
|
||||
closedir(dd->dir);
|
||||
switch(delete->mode)
|
||||
{
|
||||
case DM_COUNT:
|
||||
@ -526,7 +542,7 @@ static int _idle_do_opendir(Delete * delete, char const * filename)
|
||||
free(dd);
|
||||
return _delete_filename_error(delete, filename, 1);
|
||||
}
|
||||
if((dd->dir = browser_vfs_opendir(filename, NULL)) == NULL)
|
||||
if((dd->dir = opendir(filename)) == NULL)
|
||||
{
|
||||
free(dd);
|
||||
return _delete_filename_error(delete, filename, 1);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -30,7 +34,7 @@
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
# include <Desktop.h>
|
||||
# include "Browser/desktop.h"
|
||||
# include "../../include/Browser.h"
|
||||
# include "../common.h"
|
||||
|
||||
|
||||
@ -55,14 +59,8 @@ void desktop_delete(Desktop * desktop);
|
||||
int desktop_get_drag_data(Desktop * desktop, GtkSelectionData * seldata);
|
||||
GdkPixbuf * desktop_get_file(Desktop * desktop);
|
||||
GdkPixbuf * desktop_get_folder(Desktop * desktop);
|
||||
DesktopHandler * desktop_get_handler(Desktop * desktop);
|
||||
String const * desktop_get_home(Desktop * desktop);
|
||||
void desktop_get_icon_size(Desktop * desktop, unsigned int * width,
|
||||
unsigned int * height, unsigned int * size);
|
||||
DesktopIcon ** desktop_get_icons_selected(Desktop * desktop);
|
||||
Mime * desktop_get_mime(Desktop * desktop);
|
||||
GtkIconTheme * desktop_get_theme(Desktop * desktop);
|
||||
GtkWidget * desktop_get_window(Desktop * desktop);
|
||||
|
||||
void desktop_set_alignment(Desktop * desktop, DesktopAlignment alignment);
|
||||
void desktop_set_icons(Desktop * desktop, DesktopIcons icons);
|
||||
@ -71,19 +69,14 @@ int desktop_set_layout(Desktop * desktop, DesktopLayout layout);
|
||||
/* useful */
|
||||
int desktop_error(Desktop * desktop, char const * message, char const * error,
|
||||
int ret);
|
||||
int desktop_perror(Desktop * desktop, char const * message, int ret);
|
||||
int desktop_serror(Desktop * desktop, char const * message, int ret);
|
||||
|
||||
void desktop_refresh(Desktop * desktop);
|
||||
void desktop_reset(Desktop * desktop);
|
||||
|
||||
void desktop_icon_add(Desktop * desktop, DesktopIcon * icon, gboolean align);
|
||||
int desktop_icon_remove(Desktop * desktop, DesktopIcon * icon, gboolean align);
|
||||
void desktop_icon_add(Desktop * desktop, DesktopIcon * icon);
|
||||
void desktop_icon_remove(Desktop * desktop, DesktopIcon * icon);
|
||||
|
||||
void desktop_icons_align(Desktop * desktop);
|
||||
void desktop_icons_cleanup(Desktop * desktop, gboolean align);
|
||||
DesktopIcon * desktop_icons_lookup(Desktop * desktop, String const * name);
|
||||
void desktop_icons_remove_all(Desktop * desktop);
|
||||
void desktop_icons_sort(Desktop * desktop);
|
||||
|
||||
void desktop_select_all(Desktop * desktop);
|
||||
@ -91,6 +84,4 @@ void desktop_select_above(Desktop * desktop, DesktopIcon * icon);
|
||||
void desktop_select_under(Desktop * desktop, DesktopIcon * icon);
|
||||
void desktop_unselect_all(Desktop * desktop);
|
||||
|
||||
void desktop_show_preferences(Desktop * desktop);
|
||||
|
||||
#endif /* !BROWSER_DESKTOP_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -31,24 +35,20 @@
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <System/error.h>
|
||||
#include <Desktop.h>
|
||||
#include "../../include/Browser/desktop.h"
|
||||
#include "../../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME_DESKTOPCTL
|
||||
# define PROGNAME_DESKTOPCTL "desktopctl"
|
||||
#endif
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local"
|
||||
# define PREFIX "/usr/local"
|
||||
#endif
|
||||
#ifndef DATADIR
|
||||
# define DATADIR PREFIX "/share"
|
||||
# define DATADIR PREFIX "/share"
|
||||
#endif
|
||||
#ifndef LOCALEDIR
|
||||
# define LOCALEDIR DATADIR "/locale"
|
||||
# define LOCALEDIR DATADIR "/locale"
|
||||
#endif
|
||||
|
||||
|
||||
@ -65,9 +65,7 @@ static int _usage(void);
|
||||
/* desktopctl */
|
||||
static int _desktopctl(int action, int what)
|
||||
{
|
||||
if(desktop_message_send(DESKTOP_CLIENT_MESSAGE, action, what, TRUE)
|
||||
!= 0)
|
||||
return error_print(PROGNAME_DESKTOPCTL);
|
||||
desktop_message_send(DESKTOP_CLIENT_MESSAGE, action, what, TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -75,7 +73,7 @@ static int _desktopctl(int action, int what)
|
||||
/* desktopctl_error */
|
||||
static int _desktopctl_error(char const * message, int ret)
|
||||
{
|
||||
fprintf(stderr, "%s: ", PROGNAME_DESKTOPCTL);
|
||||
fputs("desktopctl: ", stderr);
|
||||
perror(message);
|
||||
return ret;
|
||||
}
|
||||
@ -84,7 +82,7 @@ static int _desktopctl_error(char const * message, int ret)
|
||||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fprintf(stderr, _("Usage: %s [-H|-L|-P|-R|-S|-T|-V|-a|-c|-f|-h|-n]\n"
|
||||
fputs(_("Usage: desktopctl [-H|-L|-P|-R|-S|-T|-V|-a|-c|-f|-h|-n]\n"
|
||||
" -H Place icons horizontally\n"
|
||||
" -L Rotate screen to landscape mode\n"
|
||||
" -P Rotate screen to portrait mode\n"
|
||||
@ -96,7 +94,7 @@ static int _usage(void)
|
||||
" -c Sort the applications registered by category\n"
|
||||
" -f Display contents of the desktop folder\n"
|
||||
" -h Display the homescreen\n"
|
||||
" -n Do not display icons on the desktop\n"), PROGNAME_DESKTOPCTL);
|
||||
" -n Do not display icons on the desktop\n"), stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2010-2021 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2010-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -49,21 +53,18 @@
|
||||
|
||||
|
||||
/* constants */
|
||||
#ifndef PROGNAME
|
||||
# define PROGNAME "desktop"
|
||||
#endif
|
||||
#ifndef PROGNAME_BROWSER
|
||||
# define PROGNAME_BROWSER "browser"
|
||||
#endif
|
||||
#ifndef PROGNAME_DELETE
|
||||
# define PROGNAME_DELETE "delete"
|
||||
#endif
|
||||
#ifndef PROGNAME_DESKTOP
|
||||
# define PROGNAME_DESKTOP "desktop"
|
||||
#endif
|
||||
#ifndef PROGNAME_HTMLAPP
|
||||
# define PROGNAME_HTMLAPP "htmlapp"
|
||||
#endif
|
||||
#ifndef PROGNAME_PROPERTIES
|
||||
# define PROGNAME_PROPERTIES "properties"
|
||||
#endif
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local"
|
||||
#endif
|
||||
@ -88,7 +89,7 @@ struct _DesktopIcon
|
||||
char const * mimetype;
|
||||
|
||||
/* applications */
|
||||
MimeHandler * mime;
|
||||
Config * config;
|
||||
|
||||
/* callback */
|
||||
DesktopIconCallback callback;
|
||||
@ -106,6 +107,12 @@ struct _DesktopIcon
|
||||
};
|
||||
|
||||
|
||||
/* constants */
|
||||
static const char _desktop_type_application[] = "Application";
|
||||
static const char _desktop_type_directory[] = "Directory";
|
||||
static const char _desktop_type_url[] = "URL";
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static DesktopIcon * _desktopicon_new_do(Desktop * desktop, GdkPixbuf * image,
|
||||
char const * name);
|
||||
@ -129,10 +136,10 @@ static void _on_icon_drag_data_received(GtkWidget * widget,
|
||||
GdkDragContext * context, gint x, gint y,
|
||||
GtkSelectionData * seldata, guint info, guint time,
|
||||
gpointer data);
|
||||
static void _on_icon_edit(gpointer data);
|
||||
static void _on_icon_open(gpointer data);
|
||||
static void _on_icon_open_with(gpointer data);
|
||||
static void _on_icon_edit(gpointer data);
|
||||
static void _on_icon_run(gpointer data);
|
||||
static void _on_icon_open_with(gpointer data);
|
||||
static void _on_icon_rename(gpointer data);
|
||||
static void _on_icon_delete(gpointer data);
|
||||
static void _on_icon_properties(gpointer data);
|
||||
@ -157,7 +164,6 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
|
||||
char * p;
|
||||
GtkTargetEntry targets[] = { { "deforaos_browser_dnd", 0, 0 } };
|
||||
size_t targets_cnt = sizeof(targets) / sizeof(*targets);
|
||||
unsigned int size;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%p, \"%s\", \"%s\")\n", __func__,
|
||||
@ -172,17 +178,15 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
|
||||
isexec = (isdir == FALSE) && (s->st_mode & S_IXUSR)
|
||||
? TRUE : FALSE;
|
||||
mimetype = browser_vfs_mime_type(mime, path, s->st_mode);
|
||||
desktop_get_icon_size(desktop, NULL, NULL, &size);
|
||||
image = browser_vfs_mime_icon(mime, path, mimetype, &lst, NULL,
|
||||
size);
|
||||
DESKTOPICON_ICON_SIZE);
|
||||
}
|
||||
if(name == NULL)
|
||||
{
|
||||
if((p = g_filename_to_utf8(path, -1, NULL, NULL, &error))
|
||||
== NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: %s\n", PROGNAME_DESKTOP,
|
||||
error->message);
|
||||
fprintf(stderr, "%s%s\n", "desktop: ", error->message);
|
||||
name = path;
|
||||
}
|
||||
else
|
||||
@ -198,13 +202,14 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
|
||||
targets_cnt, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_drag_dest_set(desktopicon->event, GTK_DEST_DEFAULT_ALL, targets,
|
||||
targets_cnt, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect(desktopicon->event, "drag-data-get",
|
||||
g_signal_connect(G_OBJECT(desktopicon->event), "drag-data-get",
|
||||
G_CALLBACK(_on_icon_drag_data_get), desktopicon);
|
||||
g_signal_connect(desktopicon->event, "drag-data-received",
|
||||
g_signal_connect(G_OBJECT(desktopicon->event), "drag-data-received",
|
||||
G_CALLBACK(_on_icon_drag_data_received), desktopicon);
|
||||
desktopicon->isdir = isdir;
|
||||
desktopicon_set_executable(desktopicon, isexec);
|
||||
desktopicon->mimetype = mimetype;
|
||||
desktopicon->config = NULL;
|
||||
if(path != NULL && (desktopicon->path = strdup(path)) == NULL)
|
||||
{
|
||||
desktopicon_delete(desktopicon);
|
||||
@ -215,53 +220,46 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
|
||||
|
||||
|
||||
/* desktopicon_new_application */
|
||||
static GdkPixbuf * _new_application_icon(Desktop * desktop, String const * icon,
|
||||
static int _new_application_access(char const * path, int mode);
|
||||
static int _new_application_access_path(char const * path,
|
||||
char const * filename, int mode);
|
||||
static GdkPixbuf * _new_application_icon(Desktop * desktop, char const * icon,
|
||||
char const * datadir);
|
||||
|
||||
DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path,
|
||||
char const * datadir)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
MimeHandler * mime;
|
||||
MimeHandlerType type;
|
||||
String const * name;
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
String const * comment;
|
||||
#endif
|
||||
String const * icon;
|
||||
String const * p;
|
||||
Config * config;
|
||||
const char section[] = "Desktop Entry";
|
||||
char const * name;
|
||||
char const * icon;
|
||||
char const * p;
|
||||
GdkPixbuf * image = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%p, \"%s\")\n", __func__, (void *)desktop,
|
||||
path);
|
||||
#endif
|
||||
if((mime = mimehandler_new_load(path)) == NULL)
|
||||
if((config = config_new()) == NULL)
|
||||
return NULL;
|
||||
if(mimehandler_is_deleted(mime)
|
||||
|| ((type = mimehandler_get_type(mime))
|
||||
!= MIMEHANDLER_TYPE_APPLICATION
|
||||
&& type != MIMEHANDLER_TYPE_DIRECTORY
|
||||
&& type != MIMEHANDLER_TYPE_LINK)
|
||||
|| (name = mimehandler_get_name(mime, 1)) == NULL
|
||||
|| mimehandler_can_display(mime) == 0
|
||||
|| mimehandler_can_execute(mime) == 0)
|
||||
if(config_load(config, path) != 0
|
||||
|| ((p = config_get(config, section, "Hidden")) != NULL
|
||||
&& strcmp(p, "true") == 0)
|
||||
|| (p = config_get(config, section, "Type")) == NULL
|
||||
|| (strcmp(p, _desktop_type_application) != 0
|
||||
&& strcmp(p, _desktop_type_directory) != 0
|
||||
&& strcmp(p, _desktop_type_url) != 0)
|
||||
|| (name = config_get(config, section, "Name")) == NULL
|
||||
|| ((p = config_get(config, section, "NoDisplay"))
|
||||
!= NULL && strcmp(p, "true") == 0)
|
||||
|| ((p = config_get(config, section, "TryExec")) != NULL
|
||||
&& _new_application_access(p, X_OK) != 0))
|
||||
{
|
||||
mimehandler_delete(mime);
|
||||
config_delete(config);
|
||||
return NULL;
|
||||
}
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
comment = mimehandler_get_comment(mime, 1);
|
||||
#endif
|
||||
if((p = mimehandler_get_generic_name(mime, 1)) != NULL)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if(comment == NULL)
|
||||
comment = name;
|
||||
#endif
|
||||
name = p;
|
||||
}
|
||||
if((icon = mimehandler_get_icon(mime, 1)) == NULL)
|
||||
if((icon = config_get(config, section, "Icon")) == NULL)
|
||||
icon = "application-x-executable";
|
||||
image = _new_application_icon(desktop, icon, datadir);
|
||||
desktopicon = _desktopicon_new_do(desktop, image, name);
|
||||
@ -269,25 +267,71 @@ DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path,
|
||||
g_object_unref(image);
|
||||
if(desktopicon == NULL)
|
||||
{
|
||||
mimehandler_delete(mime);
|
||||
config_delete(config);
|
||||
return NULL;
|
||||
}
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
if(comment != NULL)
|
||||
gtk_widget_set_tooltip_text(desktopicon->event, comment);
|
||||
#endif
|
||||
desktopicon->mime = mime;
|
||||
desktopicon->config = config;
|
||||
desktopicon_set_confirm(desktopicon, FALSE);
|
||||
desktopicon_set_executable(desktopicon, TRUE);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
return desktopicon;
|
||||
}
|
||||
|
||||
static GdkPixbuf * _new_application_icon(Desktop * desktop, String const * icon,
|
||||
static int _new_application_access(char const * path, int mode)
|
||||
{
|
||||
int ret = -1;
|
||||
char const * p;
|
||||
char * q;
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
if(path[0] == '/')
|
||||
return access(path, mode);
|
||||
if((p = getenv("PATH")) == NULL)
|
||||
return 0;
|
||||
if((q = strdup(p)) == NULL)
|
||||
return 0;
|
||||
errno = ENOENT;
|
||||
for(i = 0, j = 0;; i++)
|
||||
if(q[i] == '\0')
|
||||
{
|
||||
ret = _new_application_access_path(&q[j], path, mode);
|
||||
break;
|
||||
}
|
||||
else if(q[i] == ':')
|
||||
{
|
||||
q[i] = '\0';
|
||||
if((ret = _new_application_access_path(&q[j], path,
|
||||
mode)) == 0)
|
||||
break;
|
||||
j = i + 1;
|
||||
}
|
||||
free(q);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _new_application_access_path(char const * path,
|
||||
char const * filename, int mode)
|
||||
{
|
||||
int ret;
|
||||
char * p;
|
||||
size_t len;
|
||||
|
||||
len = strlen(path) + 1 + strlen(filename) + 1;
|
||||
if((p = malloc(len)) == NULL)
|
||||
return -1;
|
||||
snprintf(p, len, "%s/%s", path, filename);
|
||||
ret = access(p, mode);
|
||||
free(p);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GdkPixbuf * _new_application_icon(Desktop * desktop, char const * icon,
|
||||
char const * datadir)
|
||||
{
|
||||
const char pixmaps[] = "/pixmaps/";
|
||||
unsigned int size;
|
||||
const int width = DESKTOPICON_ICON_SIZE;
|
||||
const int height = DESKTOPICON_ICON_SIZE;
|
||||
String * buf;
|
||||
GdkPixbuf * pixbuf = NULL;
|
||||
GError * error = NULL;
|
||||
@ -295,9 +339,8 @@ static GdkPixbuf * _new_application_icon(Desktop * desktop, String const * icon,
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\", \"%s\")\n", __func__, icon, datadir);
|
||||
#endif
|
||||
desktop_get_icon_size(desktop, NULL, NULL, &size);
|
||||
if(icon[0] == '/')
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size(icon, size, size,
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size(icon, width, height,
|
||||
&error);
|
||||
else if(strchr(icon, '.') != NULL)
|
||||
{
|
||||
@ -306,8 +349,8 @@ static GdkPixbuf * _new_application_icon(Desktop * desktop, String const * icon,
|
||||
if((buf = string_new_append(datadir, pixmaps, icon, NULL))
|
||||
!= NULL)
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size(buf, size,
|
||||
size, &error);
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size(buf, width,
|
||||
height, &error);
|
||||
string_delete(buf);
|
||||
}
|
||||
}
|
||||
@ -318,7 +361,7 @@ static GdkPixbuf * _new_application_icon(Desktop * desktop, String const * icon,
|
||||
}
|
||||
if(pixbuf == NULL)
|
||||
pixbuf = gtk_icon_theme_load_icon(desktop_get_theme(desktop),
|
||||
icon, size, 0, NULL);
|
||||
icon, DESKTOPICON_ICON_SIZE, 0, NULL);
|
||||
if(pixbuf == NULL)
|
||||
pixbuf = desktop_get_file(desktop);
|
||||
return pixbuf;
|
||||
@ -330,16 +373,14 @@ DesktopIcon * desktopicon_new_category(Desktop * desktop, char const * name,
|
||||
char const * icon)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
unsigned int size;
|
||||
GdkPixbuf * image;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%p, \"%s\", \"%s\")\n", __func__,
|
||||
(void *)desktop, name, icon);
|
||||
#endif
|
||||
desktop_get_icon_size(desktop, NULL, NULL, &size);
|
||||
image = gtk_icon_theme_load_icon(desktop_get_theme(desktop), icon, size,
|
||||
0, NULL);
|
||||
image = gtk_icon_theme_load_icon(desktop_get_theme(desktop), icon,
|
||||
DESKTOPICON_ICON_SIZE, 0, NULL);
|
||||
if((desktopicon = _desktopicon_new_do(desktop, image, name)) == NULL)
|
||||
return NULL;
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
@ -350,8 +391,8 @@ DesktopIcon * desktopicon_new_category(Desktop * desktop, char const * name,
|
||||
/* desktopicon_delete */
|
||||
void desktopicon_delete(DesktopIcon * desktopicon)
|
||||
{
|
||||
if(desktopicon->mime != NULL)
|
||||
mimehandler_delete(desktopicon->mime);
|
||||
if(desktopicon->config != NULL)
|
||||
config_delete(desktopicon->config);
|
||||
free(desktopicon->name);
|
||||
free(desktopicon->path);
|
||||
gtk_widget_destroy(desktopicon->event);
|
||||
@ -360,13 +401,6 @@ void desktopicon_delete(DesktopIcon * desktopicon)
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* desktopicon_get_desktop */
|
||||
Desktop * desktopicon_get_desktop(DesktopIcon * desktopicon)
|
||||
{
|
||||
return desktopicon->desktop;
|
||||
}
|
||||
|
||||
|
||||
/* desktopicon_get_first */
|
||||
gboolean desktopicon_get_first(DesktopIcon * desktopicon)
|
||||
{
|
||||
@ -525,7 +559,7 @@ int desktopicon_set_name(DesktopIcon * desktopicon, char const * name)
|
||||
void desktopicon_set_selected(DesktopIcon * desktopicon, gboolean selected)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %p is %s\n", (void *)desktopicon,
|
||||
fprintf(stderr, "DEBUG: %p is %s\n", (void*)desktopicon,
|
||||
selected ? "selected" : "deselected");
|
||||
#endif
|
||||
desktopicon->selected = selected;
|
||||
@ -562,30 +596,31 @@ static DesktopIcon * _desktopicon_new_do(Desktop * desktop, GdkPixbuf * image,
|
||||
char const * name)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
unsigned int size;
|
||||
GtkWidget * vbox;
|
||||
|
||||
if((desktopicon = object_new(sizeof(*desktopicon))) == NULL)
|
||||
return NULL;
|
||||
memset(desktopicon, 0, sizeof(*desktopicon));
|
||||
desktop_get_icon_size(desktop, NULL, NULL, &size);
|
||||
desktopicon->desktop = desktop;
|
||||
desktopicon->confirm = TRUE;
|
||||
desktopicon->updated = TRUE;
|
||||
/* widget */
|
||||
desktopicon->window = NULL;
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 4);
|
||||
#endif
|
||||
/* event */
|
||||
desktopicon->event = gtk_event_box_new();
|
||||
gtk_event_box_set_visible_window(GTK_EVENT_BOX(desktopicon->event),
|
||||
FALSE);
|
||||
g_signal_connect(desktopicon->event, "button-press-event",
|
||||
g_signal_connect(G_OBJECT(desktopicon->event), "button-press-event",
|
||||
G_CALLBACK(_on_icon_button_press), desktopicon);
|
||||
g_signal_connect(desktopicon->event, "key-press-event",
|
||||
g_signal_connect(G_OBJECT(desktopicon->event), "key-press-event",
|
||||
G_CALLBACK(_on_icon_key_press), desktopicon);
|
||||
/* image */
|
||||
desktopicon->image = gtk_image_new();
|
||||
gtk_widget_set_size_request(desktopicon->image, size, size);
|
||||
gtk_widget_set_size_request(desktopicon->image, DESKTOPICON_ICON_SIZE,
|
||||
DESKTOPICON_ICON_SIZE);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), desktopicon->image, FALSE, TRUE, 0);
|
||||
/* label */
|
||||
desktopicon->label = gtk_label_new(NULL);
|
||||
@ -621,19 +656,18 @@ static void _desktopicon_set_icon(DesktopIcon * desktopicon, GdkPixbuf * icon)
|
||||
{
|
||||
GdkPixbuf * i = NULL;
|
||||
#ifdef EMBEDDED
|
||||
const GdkInterpType interp = GDK_INTERP_BILINEAR;
|
||||
const GdkInterpType interp = GDK_INTERP_NEAREST;
|
||||
#else
|
||||
const GdkInterpType interp = GDK_INTERP_HYPER;
|
||||
#endif
|
||||
unsigned int size;
|
||||
|
||||
if(icon == NULL)
|
||||
return;
|
||||
desktop_get_icon_size(desktopicon->desktop, NULL, NULL, &size);
|
||||
if(gdk_pixbuf_get_width(icon) != size
|
||||
&& gdk_pixbuf_get_height(icon) != size
|
||||
&& (i = gdk_pixbuf_scale_simple(icon, size, size,
|
||||
interp)) != NULL)
|
||||
if(gdk_pixbuf_get_width(icon) != DESKTOPICON_ICON_SIZE
|
||||
&& gdk_pixbuf_get_height(icon) != DESKTOPICON_ICON_SIZE
|
||||
&& (i = gdk_pixbuf_scale_simple(icon,
|
||||
DESKTOPICON_ICON_SIZE,
|
||||
DESKTOPICON_ICON_SIZE, interp)) != NULL)
|
||||
icon = i;
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(desktopicon->image), icon);
|
||||
if(i != NULL)
|
||||
@ -662,7 +696,10 @@ static void _desktopicon_update_transparency(DesktopIcon * desktopicon)
|
||||
GdkPixbuf * pixbuf;
|
||||
int width;
|
||||
int height;
|
||||
#if !GTK_CHECK_VERSION(3, 0, 0)
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
|
||||
#else
|
||||
int iwidth;
|
||||
int iheight;
|
||||
GdkBitmap * mask;
|
||||
@ -671,7 +708,6 @@ static void _desktopicon_update_transparency(DesktopIcon * desktopicon)
|
||||
GdkColor black = { 0, 0, 0, 0 };
|
||||
GdkColor white = { 0xffffffff, 0xffff, 0xffff, 0xffff };
|
||||
int offset;
|
||||
unsigned int size;
|
||||
#endif
|
||||
GtkRequisition req;
|
||||
|
||||
@ -689,7 +725,6 @@ static void _desktopicon_update_transparency(DesktopIcon * desktopicon)
|
||||
/* FIXME re-implement */
|
||||
gtk_widget_get_preferred_size(desktopicon->label, NULL, &req);
|
||||
#else
|
||||
desktop_get_icon_size(desktopicon->desktop, NULL, NULL, &size);
|
||||
iwidth = gdk_pixbuf_get_width(pixbuf);
|
||||
iheight = gdk_pixbuf_get_height(pixbuf);
|
||||
mask = gdk_pixmap_new(NULL, width, height, 1);
|
||||
@ -698,14 +733,14 @@ static void _desktopicon_update_transparency(DesktopIcon * desktopicon)
|
||||
gdk_gc_set_foreground(gc, &black);
|
||||
gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height);
|
||||
gdk_draw_drawable(mask, gc, iconmask, 0, 0, (width - iwidth) / 2,
|
||||
(size - iheight) / 2, -1, -1);
|
||||
(DESKTOPICON_ICON_SIZE - iheight) / 2, -1, -1);
|
||||
gdk_gc_set_foreground(gc, &white);
|
||||
gtk_widget_size_request(desktopicon->label, &req);
|
||||
# ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\") label is %dx%d\n", __func__,
|
||||
desktopicon->name, req.width, req.height);
|
||||
# endif
|
||||
offset = size + 4;
|
||||
offset = DESKTOPICON_ICON_SIZE + 4;
|
||||
gdk_draw_rectangle(mask, gc, TRUE, (width - req.width - 8) / 2,
|
||||
offset /* + ((height - offset - req.height - 8)
|
||||
/ 2) */, req.width + 8, req.height + 8);
|
||||
@ -777,7 +812,7 @@ static gboolean _on_icon_button_press(GtkWidget * widget,
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE,
|
||||
NULL);
|
||||
g_signal_connect_swapped(menuitem, "activate",
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_delete), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
@ -787,7 +822,7 @@ static gboolean _on_icon_button_press(GtkWidget * widget,
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_from_stock(
|
||||
GTK_STOCK_PROPERTIES, NULL);
|
||||
g_signal_connect_swapped(menuitem, "activate",
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_properties), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
@ -801,7 +836,7 @@ static void _popup_directory(GtkWidget * menu, DesktopIcon * desktopicon)
|
||||
GtkWidget * menuitem;
|
||||
|
||||
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
|
||||
_on_icon_open), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
if(desktopicon->immutable == FALSE)
|
||||
@ -809,8 +844,8 @@ static void _popup_directory(GtkWidget * menu, DesktopIcon * desktopicon)
|
||||
menuitem = gtk_separator_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_menu_item_new_with_mnemonic(_("_Rename..."));
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_icon_rename), desktopicon);
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_rename), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
}
|
||||
@ -820,8 +855,8 @@ static void _popup_callback(GtkWidget * menu, DesktopIcon * desktopicon)
|
||||
GtkWidget * menuitem;
|
||||
|
||||
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_icon_open), desktopicon);
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_open), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
|
||||
@ -844,15 +879,15 @@ static void _popup_file(GtkWidget * menu, DesktopIcon * desktopicon)
|
||||
{
|
||||
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_EXECUTE,
|
||||
NULL);
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_icon_run), desktopicon);
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_run), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
if(desktopicon->path != NULL && desktopicon->path[0] == '/')
|
||||
{
|
||||
menuitem = gtk_menu_item_new_with_mnemonic(_("Open _with..."));
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_icon_open_with), desktopicon);
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_open_with), desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
if(desktopicon->immutable == FALSE)
|
||||
{
|
||||
@ -860,7 +895,7 @@ static void _popup_file(GtkWidget * menu, DesktopIcon * desktopicon)
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_menu_item_new_with_mnemonic(
|
||||
_("_Rename..."));
|
||||
g_signal_connect_swapped(menuitem, "activate",
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
|
||||
G_CALLBACK(_on_icon_rename),
|
||||
desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
@ -880,22 +915,12 @@ static void _popup_mime(Mime * mime, char const * mimetype, char const * action,
|
||||
menuitem = gtk_image_menu_item_new_from_stock(label, NULL);
|
||||
else
|
||||
menuitem = gtk_menu_item_new_with_mnemonic(label);
|
||||
g_signal_connect_swapped(menuitem, "activate", callback, desktopicon);
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate", callback,
|
||||
desktopicon);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
}
|
||||
|
||||
|
||||
/* on_icon_edit */
|
||||
static void _on_icon_edit(gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
Mime * mime;
|
||||
|
||||
mime = desktop_get_mime(desktopicon->desktop);
|
||||
mime_action(mime, "edit", desktopicon->path);
|
||||
}
|
||||
|
||||
|
||||
/* on_icon_open */
|
||||
static void _on_icon_open(gpointer data)
|
||||
{
|
||||
@ -929,35 +954,14 @@ static void _on_icon_open(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* on_icon_open_with */
|
||||
static void _on_icon_open_with(gpointer data)
|
||||
/* on_icon_edit */
|
||||
static void _on_icon_edit(gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
GtkWidget * dialog;
|
||||
char * filename = NULL;
|
||||
char * argv[] = { NULL, NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_SEARCH_PATH;
|
||||
GError * error = NULL;
|
||||
Mime * mime;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new(_("Open with..."), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
|
||||
dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
if(filename == NULL)
|
||||
return;
|
||||
argv[0] = filename;
|
||||
argv[1] = desktopicon->path;
|
||||
if(g_spawn_async(NULL, argv, NULL, flags, NULL, NULL, NULL, &error)
|
||||
!= TRUE)
|
||||
{
|
||||
desktop_error(desktopicon->desktop, NULL, error->message, 1);
|
||||
g_error_free(error);
|
||||
}
|
||||
g_free(filename);
|
||||
mime = desktop_get_mime(desktopicon->desktop);
|
||||
mime_action(mime, "edit", desktopicon->path);
|
||||
}
|
||||
|
||||
|
||||
@ -966,42 +970,39 @@ static void _run_application(DesktopIcon * desktopicon);
|
||||
static void _run_binary(DesktopIcon * desktopicon);
|
||||
static gboolean _run_confirm(void);
|
||||
static void _run_directory(DesktopIcon * desktopicon);
|
||||
static void _run_link(DesktopIcon * desktopicon);
|
||||
static void _run_url(DesktopIcon * desktopicon);
|
||||
|
||||
static void _on_icon_run(gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
const char section[] = "Desktop Entry";
|
||||
char const * p;
|
||||
|
||||
if(desktopicon->confirm != FALSE && _run_confirm() != TRUE)
|
||||
return;
|
||||
if(desktopicon->mime == NULL)
|
||||
if(desktopicon->config == NULL)
|
||||
_run_binary(desktopicon);
|
||||
switch(mimehandler_get_type(desktopicon->mime))
|
||||
{
|
||||
case MIMEHANDLER_TYPE_APPLICATION:
|
||||
_run_application(desktopicon);
|
||||
break;
|
||||
case MIMEHANDLER_TYPE_DIRECTORY:
|
||||
_run_directory(desktopicon);
|
||||
break;
|
||||
case MIMEHANDLER_TYPE_LINK:
|
||||
_run_link(desktopicon);
|
||||
break;
|
||||
case MIMEHANDLER_TYPE_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
else if((p = config_get(desktopicon->config, section, "Type")) == NULL)
|
||||
return;
|
||||
else if(strcmp(p, _desktop_type_application) == 0)
|
||||
_run_application(desktopicon);
|
||||
else if(strcmp(p, _desktop_type_directory) == 0)
|
||||
_run_directory(desktopicon);
|
||||
else if(strcmp(p, _desktop_type_url) == 0)
|
||||
_run_url(desktopicon);
|
||||
}
|
||||
|
||||
static void _run_application(DesktopIcon * desktopicon)
|
||||
{
|
||||
/* XXX code duplicated from DeforaOS Panel */
|
||||
const char section[] = "Desktop Entry";
|
||||
char * program;
|
||||
char * p;
|
||||
char const * q;
|
||||
pid_t pid;
|
||||
GError * error = NULL;
|
||||
|
||||
if((q = mimehandler_get_program(desktopicon->mime)) == NULL)
|
||||
if((q = config_get(desktopicon->config, section, "Exec")) == NULL)
|
||||
return;
|
||||
if((program = strdup(q)) == NULL)
|
||||
return; /* XXX report error */
|
||||
@ -1011,7 +1012,7 @@ static void _run_application(DesktopIcon * desktopicon)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"", __func__, program);
|
||||
#endif
|
||||
if((q = mimehandler_get_path(desktopicon->mime)) == NULL)
|
||||
if((q = config_get(desktopicon->config, section, "Path")) == NULL)
|
||||
{
|
||||
/* execute the program directly */
|
||||
if(g_spawn_command_line_async(program, &error) != TRUE)
|
||||
@ -1076,6 +1077,7 @@ static gboolean _run_confirm(void)
|
||||
|
||||
static void _run_directory(DesktopIcon * desktopicon)
|
||||
{
|
||||
const char section[] = "Desktop Entry";
|
||||
char const * directory;
|
||||
/* XXX open with the default file manager instead */
|
||||
char * argv[] = { BINDIR "/" PROGNAME_BROWSER, PROGNAME_BROWSER, "--",
|
||||
@ -1084,7 +1086,8 @@ static void _run_directory(DesktopIcon * desktopicon)
|
||||
GError * error = NULL;
|
||||
|
||||
/* XXX this may not might the correct key */
|
||||
if((directory = mimehandler_get_path(desktopicon->mime)) == NULL)
|
||||
if((directory = config_get(desktopicon->config, section, "Path"))
|
||||
== NULL)
|
||||
return;
|
||||
if((argv[2] = strdup(directory)) == NULL)
|
||||
desktop_error(desktopicon->desktop, NULL, strerror(errno), 1);
|
||||
@ -1097,16 +1100,17 @@ static void _run_directory(DesktopIcon * desktopicon)
|
||||
free(argv[2]);
|
||||
}
|
||||
|
||||
static void _run_link(DesktopIcon * desktopicon)
|
||||
static void _run_url(DesktopIcon * desktopicon)
|
||||
{
|
||||
const char section[] = "Desktop Entry";
|
||||
char const * url;
|
||||
/* XXX open with the default web browser instead */
|
||||
char * argv[] = { BINDIR "/" PROGNAME_HTMLAPP, PROGNAME_HTMLAPP, "--",
|
||||
NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_FILE_AND_ARGV_ZERO;
|
||||
char * argv[] = { PROGNAME_HTMLAPP, "--", NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_SEARCH_PATH;
|
||||
GError * error = NULL;
|
||||
|
||||
if((url = mimehandler_get_url(desktopicon->mime)) == NULL)
|
||||
if((url = config_get(desktopicon->config, section, _desktop_type_url))
|
||||
== NULL)
|
||||
return;
|
||||
if((argv[2] = strdup(url)) == NULL)
|
||||
desktop_error(desktopicon->desktop, NULL, strerror(errno), 1);
|
||||
@ -1120,6 +1124,40 @@ static void _run_link(DesktopIcon * desktopicon)
|
||||
}
|
||||
|
||||
|
||||
/* on_icon_open_with */
|
||||
static void _on_icon_open_with(gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
GtkWidget * dialog;
|
||||
char * filename = NULL;
|
||||
char * argv[] = { NULL, NULL, NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_SEARCH_PATH
|
||||
| G_SPAWN_FILE_AND_ARGV_ZERO;
|
||||
GError * error = NULL;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new(_("Open with..."), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
|
||||
GTK_RESPONSE_ACCEPT, NULL);
|
||||
if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
|
||||
dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
if(filename == NULL)
|
||||
return;
|
||||
argv[0] = filename;
|
||||
argv[1] = filename;
|
||||
argv[2] = desktopicon->path;
|
||||
if(g_spawn_async(NULL, argv, NULL, flags, NULL, NULL, NULL, &error)
|
||||
!= TRUE)
|
||||
{
|
||||
desktop_error(desktopicon->desktop, NULL, error->message, 1);
|
||||
g_error_free(error);
|
||||
}
|
||||
g_free(filename);
|
||||
}
|
||||
|
||||
|
||||
/* on_icon_rename */
|
||||
static void _on_icon_rename(gpointer data)
|
||||
{
|
||||
@ -1143,7 +1181,11 @@ static void _on_icon_rename(gpointer data)
|
||||
vbox = GTK_DIALOG(dialog)->vbox;
|
||||
#endif
|
||||
group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Rename: "));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
|
||||
@ -1158,7 +1200,11 @@ static void _on_icon_rename(gpointer data)
|
||||
gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
||||
/* entry */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("To: "));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
|
||||
@ -1238,8 +1284,8 @@ static void _on_icon_delete(gpointer data)
|
||||
static void _on_icon_properties(gpointer data)
|
||||
{
|
||||
DesktopIcon * desktopicon = data;
|
||||
char * argv[] = { BINDIR "/" PROGNAME_PROPERTIES, PROGNAME_PROPERTIES,
|
||||
"--", NULL, NULL };
|
||||
char * argv[] = { BINDIR "/properties", "properties", "--", NULL,
|
||||
NULL };
|
||||
const unsigned int flags = G_SPAWN_FILE_AND_ARGV_ZERO;
|
||||
GError * error = NULL;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2010-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2010-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -29,7 +33,6 @@
|
||||
# define BROWSER_DESKTOPICON_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
# include "Browser/desktop.h"
|
||||
# include "../common.h"
|
||||
|
||||
|
||||
@ -40,6 +43,10 @@ typedef void (*DesktopIconCallback)(Desktop * desktop, gpointer data);
|
||||
|
||||
/* constants */
|
||||
#define DESKTOPICON_ICON_SIZE 48
|
||||
#define DESKTOPICON_MAX_HEIGHT (DESKTOPICON_ICON_SIZE + 40)
|
||||
#define DESKTOPICON_MAX_WIDTH (DESKTOPICON_ICON_SIZE << 1)
|
||||
#define DESKTOPICON_MIN_HEIGHT DESKTOPICON_MAX_HEIGHT
|
||||
#define DESKTOPICON_MIN_WIDTH DESKTOPICON_MAX_WIDTH
|
||||
|
||||
|
||||
/* functions */
|
||||
@ -52,7 +59,6 @@ DesktopIcon * desktopicon_new_category(Desktop * desktop, char const * name,
|
||||
void desktopicon_delete(DesktopIcon * desktopicon);
|
||||
|
||||
/* accessors */
|
||||
Desktop * desktopicon_get_desktop(DesktopIcon * desktopicon);
|
||||
gboolean desktopicon_get_first(DesktopIcon * desktopicon);
|
||||
GtkWidget * desktopicon_get_image(DesktopIcon * desktopicon);
|
||||
gboolean desktopicon_get_immutable(DesktopIcon * desktopicon);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2016-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2016-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -25,13 +29,9 @@
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include "desktop.h"
|
||||
#include "desktopicon.h"
|
||||
#include "desktopiconwindow.h"
|
||||
|
||||
@ -55,16 +55,13 @@ static gboolean _on_desktopiconwindow_closex(void);
|
||||
DesktopIconWindow * desktopiconwindow_new(DesktopIcon * icon)
|
||||
{
|
||||
DesktopIconWindow * window;
|
||||
Desktop * desktop;
|
||||
GtkWindow * w;
|
||||
GdkGeometry geometry;
|
||||
/* XXX check */
|
||||
const unsigned int hints = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE
|
||||
| GDK_HINT_BASE_SIZE;
|
||||
GtkWidget * widget;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int size;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%p)\n", __func__, icon);
|
||||
#endif
|
||||
if((window = object_new(sizeof(*window))) == NULL)
|
||||
return NULL;
|
||||
/* window */
|
||||
@ -75,17 +72,23 @@ DesktopIconWindow * desktopiconwindow_new(DesktopIcon * icon)
|
||||
gtk_window_set_focus_on_map(w, FALSE);
|
||||
#endif
|
||||
gtk_window_set_keep_below(w, TRUE);
|
||||
gtk_window_set_resizable(w, FALSE);
|
||||
gtk_window_set_skip_pager_hint(w, TRUE);
|
||||
#ifdef EMBEDDED
|
||||
gtk_window_set_type_hint(w, GDK_WINDOW_TYPE_HINT_UTILITY);
|
||||
#else
|
||||
gtk_window_set_type_hint(w, GDK_WINDOW_TYPE_HINT_DOCK);
|
||||
#endif
|
||||
desktop = desktopicon_get_desktop(icon);
|
||||
desktop_get_icon_size(desktop, &width, &height, &size);
|
||||
gtk_window_set_default_size(w, width, height);
|
||||
g_signal_connect(window->widget, "delete-event", G_CALLBACK(
|
||||
_on_desktopiconwindow_closex), NULL);
|
||||
memset(&geometry, 0, sizeof(geometry));
|
||||
geometry.min_width = DESKTOPICON_MIN_WIDTH;
|
||||
geometry.min_height = DESKTOPICON_MIN_HEIGHT;
|
||||
geometry.max_width = DESKTOPICON_MAX_WIDTH;
|
||||
geometry.max_height = DESKTOPICON_MAX_HEIGHT;
|
||||
geometry.base_width = DESKTOPICON_MIN_WIDTH;
|
||||
geometry.base_height = DESKTOPICON_MIN_HEIGHT;
|
||||
gtk_window_set_geometry_hints(w, NULL, &geometry, hints);
|
||||
/* icon */
|
||||
widget = desktopicon_get_widget(icon);
|
||||
gtk_container_add(GTK_CONTAINER(window->widget), widget);
|
||||
|
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
@ -1,245 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "desktop.h"
|
||||
#include "desktopicon.h"
|
||||
#include "desktopiconwindow.h"
|
||||
#include "handler.h"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) string
|
||||
|
||||
#define COMMON_SYMLINK
|
||||
#include "../common.c"
|
||||
|
||||
|
||||
/* DesktopHandler */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _DesktopCategory
|
||||
{
|
||||
gboolean show;
|
||||
char const * category;
|
||||
char const * name;
|
||||
char const * icon;
|
||||
} DesktopCategory;
|
||||
|
||||
typedef struct _DesktopHandlerApplications
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
GSList * apps;
|
||||
DesktopCategory * category;
|
||||
} DesktopHandlerApplications;
|
||||
|
||||
typedef struct _DesktopHandlerCategories
|
||||
{
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
GSList * apps;
|
||||
} DesktopHandlerCategories;
|
||||
|
||||
typedef struct _DesktopHandlerFiles
|
||||
{
|
||||
char * path;
|
||||
DIR * refresh_dir;
|
||||
time_t refresh_mtime;
|
||||
guint refresh_source;
|
||||
gboolean show_hidden;
|
||||
GtkWidget * menu;
|
||||
} DesktopHandlerFiles;
|
||||
|
||||
struct _DesktopHandler
|
||||
{
|
||||
Desktop * desktop;
|
||||
DesktopIcons icons;
|
||||
union
|
||||
{
|
||||
DesktopHandlerApplications applications;
|
||||
DesktopHandlerCategories categories;
|
||||
DesktopHandlerFiles files;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
/* constants */
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local"
|
||||
#endif
|
||||
#ifndef DATADIR
|
||||
# define DATADIR PREFIX "/share"
|
||||
#endif
|
||||
|
||||
#define DESKTOP ".desktop"
|
||||
|
||||
#define IDLE_LOOP_ICON_CNT 16 /* number of icons added in a loop */
|
||||
|
||||
|
||||
#include "handler/applications.c"
|
||||
#include "handler/categories.c"
|
||||
#include "handler/files.c"
|
||||
#include "handler/homescreen.c"
|
||||
|
||||
|
||||
/* protected */
|
||||
/* functions */
|
||||
/* desktophandler_new */
|
||||
DesktopHandler * desktophandler_new(Desktop * desktop, DesktopIcons icons)
|
||||
{
|
||||
DesktopHandler * handler;
|
||||
|
||||
if((handler = object_new(sizeof(*handler))) == NULL)
|
||||
return NULL;
|
||||
handler->desktop = desktop;
|
||||
handler->icons = DESKTOP_ICONS_NONE;
|
||||
desktophandler_set_icons(handler, icons);
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_delete */
|
||||
void desktophandler_delete(DesktopHandler * handler)
|
||||
{
|
||||
desktophandler_set_icons(handler, DESKTOP_ICONS_NONE);
|
||||
object_delete(handler);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
static void _set_icons_destroy(DesktopHandler * handler);
|
||||
static void _set_icons_init(DesktopHandler * handler);
|
||||
|
||||
void desktophandler_set_icons(DesktopHandler * handler, DesktopIcons icons)
|
||||
{
|
||||
if(handler->icons != icons)
|
||||
{
|
||||
desktop_icons_remove_all(handler->desktop);
|
||||
_set_icons_destroy(handler);
|
||||
handler->icons = icons;
|
||||
_set_icons_init(handler);
|
||||
}
|
||||
}
|
||||
|
||||
static void _set_icons_destroy(DesktopHandler * handler)
|
||||
{
|
||||
switch(handler->icons)
|
||||
{
|
||||
case DESKTOP_ICONS_APPLICATIONS:
|
||||
_desktophandler_applications_destroy(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_CATEGORIES:
|
||||
_desktophandler_categories_destroy(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_FILES:
|
||||
_desktophandler_files_destroy(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_HOMESCREEN:
|
||||
_desktophandler_homescreen_destroy(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void _set_icons_init(DesktopHandler * handler)
|
||||
{
|
||||
switch(handler->icons)
|
||||
{
|
||||
case DESKTOP_ICONS_APPLICATIONS:
|
||||
_desktophandler_applications_init(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_CATEGORIES:
|
||||
_desktophandler_categories_init(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_FILES:
|
||||
_desktophandler_files_init(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_HOMESCREEN:
|
||||
_desktophandler_homescreen_init(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_popup */
|
||||
void desktophandler_popup(DesktopHandler * handler, XButtonEvent * xbev)
|
||||
{
|
||||
switch(handler->icons)
|
||||
{
|
||||
case DESKTOP_ICONS_APPLICATIONS:
|
||||
_desktophandler_applications_popup(handler, xbev);
|
||||
break;
|
||||
case DESKTOP_ICONS_CATEGORIES:
|
||||
_desktophandler_categories_popup(handler, xbev);
|
||||
break;
|
||||
case DESKTOP_ICONS_FILES:
|
||||
_desktophandler_files_popup(handler, xbev);
|
||||
break;
|
||||
case DESKTOP_ICONS_HOMESCREEN:
|
||||
_desktophandler_homescreen_popup(handler, xbev);
|
||||
break;
|
||||
case DESKTOP_ICONS_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_refresh */
|
||||
void desktophandler_refresh(DesktopHandler * handler)
|
||||
{
|
||||
switch(handler->icons)
|
||||
{
|
||||
case DESKTOP_ICONS_APPLICATIONS:
|
||||
_desktophandler_applications_refresh(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_CATEGORIES:
|
||||
_desktophandler_categories_refresh(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_FILES:
|
||||
_desktophandler_files_refresh(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_HOMESCREEN:
|
||||
_desktophandler_homescreen_refresh(handler);
|
||||
break;
|
||||
case DESKTOP_ICONS_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#ifndef BROWSER_DESKTOPHANDLER_H
|
||||
# define BROWSER_DESKTOPHANDLER_H
|
||||
|
||||
# include <X11/Xlib.h>
|
||||
# include "Browser/desktop.h"
|
||||
|
||||
|
||||
/* DesktopHandler */
|
||||
/* types */
|
||||
/* functions */
|
||||
DesktopHandler * desktophandler_new(Desktop * desktop, DesktopIcons icons);
|
||||
void desktophandler_delete(DesktopHandler * handler);
|
||||
|
||||
/* accessors */
|
||||
void desktophandler_set_icons(DesktopHandler * handler, DesktopIcons icons);
|
||||
|
||||
/* useful */
|
||||
void desktophandler_popup(DesktopHandler * handler, XButtonEvent * xbev);
|
||||
void desktophandler_refresh(DesktopHandler * handler);
|
||||
|
||||
#endif /* !BROWSER_DESKTOPHANDLER_H */
|
@ -1,374 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include "mimeapp.h"
|
||||
|
||||
|
||||
/* DesktopMimeApplications */
|
||||
/* private */
|
||||
/* prototypes */
|
||||
static void _desktophandler_applications_init(DesktopHandler * handler);
|
||||
static void _desktophandler_applications_destroy(DesktopHandler * handler);
|
||||
static void _desktophandler_applications_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev);
|
||||
static void _desktophandler_applications_refresh(DesktopHandler * handler);
|
||||
|
||||
|
||||
/* functions */
|
||||
/* desktophandler_applications_init */
|
||||
static void _applications_init_on_back(Desktop * desktop, gpointer data);
|
||||
|
||||
static void _desktophandler_applications_init(DesktopHandler * handler)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
GdkPixbuf * icon;
|
||||
unsigned int size;
|
||||
|
||||
handler->u.applications.refresh_dir = NULL;
|
||||
handler->u.applications.refresh_mtime = 0;
|
||||
handler->u.applications.refresh_source = 0;
|
||||
handler->u.applications.apps = NULL;
|
||||
handler->u.applications.category = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_HORIZONTAL);
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Back"), NULL))
|
||||
== NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, _("Back"), 1);
|
||||
return;
|
||||
}
|
||||
desktopicon_set_callback(desktopicon, _applications_init_on_back,
|
||||
handler);
|
||||
desktopicon_set_first(desktopicon, TRUE);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
desktop_get_icon_size(handler->desktop, NULL, NULL, &size);
|
||||
icon = gtk_icon_theme_load_icon(desktop_get_theme(handler->desktop),
|
||||
"back", size, 0, NULL);
|
||||
if(icon != NULL)
|
||||
desktopicon_set_icon(desktopicon, icon);
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
}
|
||||
|
||||
static void _applications_init_on_back(Desktop * desktop, gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
desktop_set_icons(desktop, (handler->u.applications.category != NULL)
|
||||
? DESKTOP_ICONS_CATEGORIES : DESKTOP_ICONS_HOMESCREEN);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_applications_destroy */
|
||||
static void _desktophandler_applications_destroy(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.applications.refresh_source != 0)
|
||||
g_source_remove(handler->u.applications.refresh_source);
|
||||
if(handler->u.applications.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.applications.refresh_dir);
|
||||
g_slist_foreach(handler->u.applications.apps, (GFunc)mimeapp_delete,
|
||||
NULL);
|
||||
g_slist_free(handler->u.applications.apps);
|
||||
handler->u.applications.apps = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_applications_popup */
|
||||
static void _desktophandler_applications_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev)
|
||||
{
|
||||
(void) handler;
|
||||
(void) xbev;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_applications_refresh */
|
||||
static gboolean _desktophandler_applications_on_refresh(gpointer data);
|
||||
static gboolean _applications_on_refresh_done(DesktopHandler * handler);
|
||||
static void _applications_on_refresh_done_applications(
|
||||
DesktopHandler * handler);
|
||||
static int _applications_on_refresh_loop(DesktopHandler * handler);
|
||||
static void _applications_on_refresh_loop_path(DesktopHandler * handler,
|
||||
char const * path, char const * apppath);
|
||||
static void _applications_on_refresh_loop_xdg(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath));
|
||||
static void _applications_on_refresh_loop_xdg_home(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath));
|
||||
static void _applications_on_refresh_loop_xdg_path(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath), char const * path);
|
||||
static gint _applications_apps_compare(gconstpointer a, gconstpointer b);
|
||||
|
||||
static void _desktophandler_applications_refresh(DesktopHandler * handler)
|
||||
{
|
||||
g_slist_foreach(handler->u.applications.apps, (GFunc)mimeapp_delete,
|
||||
NULL);
|
||||
g_slist_free(handler->u.applications.apps);
|
||||
handler->u.applications.apps = NULL;
|
||||
handler->u.applications.refresh_source = g_idle_add(
|
||||
_desktophandler_applications_on_refresh, handler);
|
||||
}
|
||||
|
||||
static gboolean _desktophandler_applications_on_refresh(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
unsigned int i;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
/* FIXME upon deletion one icon too many is removed */
|
||||
for(i = 0; i < IDLE_LOOP_ICON_CNT
|
||||
&& _applications_on_refresh_loop(handler) == 0; i++);
|
||||
if(i == IDLE_LOOP_ICON_CNT)
|
||||
return TRUE;
|
||||
return _applications_on_refresh_done(handler);
|
||||
}
|
||||
|
||||
static gboolean _applications_on_refresh_done(DesktopHandler * handler)
|
||||
{
|
||||
handler->u.applications.refresh_source = 0;
|
||||
_applications_on_refresh_done_applications(handler);
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void _applications_on_refresh_done_applications(DesktopHandler * handler)
|
||||
{
|
||||
GSList * p;
|
||||
MimeApp * mimeapp;
|
||||
MimeHandler * mime;
|
||||
String const * name;
|
||||
DesktopCategory * dc = handler->u.applications.category;
|
||||
String const ** categories;
|
||||
size_t i;
|
||||
String const * filename;
|
||||
DesktopIcon * icon;
|
||||
|
||||
for(p = handler->u.applications.apps; p != NULL; p = p->next)
|
||||
{
|
||||
mimeapp = p->data;
|
||||
mime = mimeapp_get_mime(mimeapp);
|
||||
if((name = mimehandler_get_name(mime, 1)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, NULL, 1);
|
||||
continue;
|
||||
}
|
||||
if(dc != NULL)
|
||||
{
|
||||
if((categories = mimehandler_get_categories(mime))
|
||||
== NULL || categories[0] == NULL)
|
||||
continue;
|
||||
for(i = 0; categories[i] != NULL; i++)
|
||||
if(string_compare(categories[i], dc->category)
|
||||
== 0)
|
||||
break;
|
||||
if(categories[i] == NULL)
|
||||
continue;
|
||||
}
|
||||
filename = mimehandler_get_filename(mime);
|
||||
if((icon = desktopicon_new_application(handler->desktop,
|
||||
filename,
|
||||
mimeapp_get_datadir(mimeapp)))
|
||||
== NULL)
|
||||
continue;
|
||||
desktop_icon_add(handler->desktop, icon, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static int _applications_on_refresh_loop(DesktopHandler * handler)
|
||||
{
|
||||
_applications_on_refresh_loop_xdg(handler,
|
||||
_applications_on_refresh_loop_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _applications_on_refresh_loop_path(DesktopHandler * handler,
|
||||
char const * path, char const * apppath)
|
||||
{
|
||||
DIR * dir;
|
||||
struct stat st;
|
||||
size_t alen;
|
||||
struct dirent * de;
|
||||
size_t len;
|
||||
const char ext[] = ".desktop";
|
||||
char * name = NULL;
|
||||
char * p;
|
||||
MimeHandler * mime;
|
||||
MimeApp * mimeapp;
|
||||
|
||||
if((dir = browser_vfs_opendir(apppath, &st)) == NULL)
|
||||
{
|
||||
if(errno != ENOENT)
|
||||
desktop_perror(NULL, apppath, 1);
|
||||
return;
|
||||
}
|
||||
if(st.st_mtime > handler->u.applications.refresh_mtime)
|
||||
handler->u.applications.refresh_mtime = st.st_mtime;
|
||||
alen = strlen(apppath);
|
||||
while((de = browser_vfs_readdir(dir)) != NULL)
|
||||
{
|
||||
if(de->d_name[0] == '.')
|
||||
if(de->d_name[1] == '\0' || (de->d_name[1] == '.'
|
||||
&& de->d_name[2] == '\0'))
|
||||
continue;
|
||||
len = strlen(de->d_name);
|
||||
if(len < sizeof(ext))
|
||||
continue;
|
||||
if(strncmp(&de->d_name[len - sizeof(ext) + 1], ext,
|
||||
sizeof(ext)) != 0)
|
||||
continue;
|
||||
if((p = realloc(name, alen + len + 2)) == NULL)
|
||||
{
|
||||
desktop_perror(NULL, apppath, 1);
|
||||
continue;
|
||||
}
|
||||
name = p;
|
||||
snprintf(name, alen + len + 2, "%s/%s", apppath, de->d_name);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() name=\"%s\" path=\"%s\"\n",
|
||||
__func__, name, path);
|
||||
#endif
|
||||
if((mime = mimehandler_new_load(name)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, NULL, 1);
|
||||
continue;
|
||||
}
|
||||
if(mimehandler_can_display(mime) == 0
|
||||
|| mimehandler_can_execute(mime) == 0
|
||||
|| (mimeapp = mimeapp_new(mime, path)) == NULL)
|
||||
{
|
||||
mimehandler_delete(mime);
|
||||
continue;
|
||||
}
|
||||
handler->u.applications.apps = g_slist_insert_sorted(
|
||||
handler->u.applications.apps, mimeapp,
|
||||
_applications_apps_compare);
|
||||
}
|
||||
free(name);
|
||||
browser_vfs_closedir(dir);
|
||||
}
|
||||
|
||||
static void _applications_on_refresh_loop_xdg(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath))
|
||||
{
|
||||
char const * path;
|
||||
char * p;
|
||||
size_t i;
|
||||
size_t j;
|
||||
int datadir = 1;
|
||||
|
||||
/* read through every XDG application folder */
|
||||
if((path = getenv("XDG_DATA_DIRS")) == NULL || strlen(path) == 0)
|
||||
{
|
||||
#if defined(__NetBSD__)
|
||||
/* XXX include the default path for pkgsrc */
|
||||
path = "/usr/pkg/share:" DATADIR ":/usr/share";
|
||||
#else
|
||||
path = "/usr/local/share:" DATADIR ":/usr/share";
|
||||
#endif
|
||||
datadir = 0;
|
||||
}
|
||||
if((p = strdup(path)) == NULL)
|
||||
desktop_perror(NULL, NULL, 1);
|
||||
else
|
||||
for(i = 0, j = 0;; i++)
|
||||
if(p[i] == '\0')
|
||||
{
|
||||
string_rtrim(&p[j], "/");
|
||||
_applications_on_refresh_loop_xdg_path(handler,
|
||||
callback, &p[j]);
|
||||
datadir |= (strcmp(&p[j], DATADIR) == 0);
|
||||
break;
|
||||
}
|
||||
else if(p[i] == ':')
|
||||
{
|
||||
p[i] = '\0';
|
||||
string_rtrim(&p[j], "/");
|
||||
_applications_on_refresh_loop_xdg_path(handler,
|
||||
callback, &p[j]);
|
||||
datadir |= (strcmp(&p[j], DATADIR) == 0);
|
||||
j = i + 1;
|
||||
}
|
||||
free(p);
|
||||
if(datadir == 0)
|
||||
_applications_on_refresh_loop_xdg_path(handler, callback,
|
||||
DATADIR);
|
||||
_applications_on_refresh_loop_xdg_home(handler, callback);
|
||||
}
|
||||
|
||||
static void _applications_on_refresh_loop_xdg_home(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath))
|
||||
{
|
||||
char const fallback[] = ".local/share";
|
||||
char const * path;
|
||||
char const * homedir;
|
||||
String * p;
|
||||
|
||||
/* use $XDG_DATA_HOME if set and not empty */
|
||||
if((path = getenv("XDG_DATA_HOME")) != NULL && strlen(path) > 0)
|
||||
{
|
||||
_applications_on_refresh_loop_xdg_path(handler, callback, path);
|
||||
return;
|
||||
}
|
||||
/* fallback to "$HOME/.local/share" */
|
||||
if((homedir = getenv("HOME")) == NULL)
|
||||
homedir = g_get_home_dir();
|
||||
if((p = string_new_append(homedir, "/", fallback, NULL)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, homedir, 1);
|
||||
return;
|
||||
}
|
||||
_applications_on_refresh_loop_xdg_path(handler, callback, p);
|
||||
string_delete(p);
|
||||
}
|
||||
|
||||
static void _applications_on_refresh_loop_xdg_path(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath), char const * path)
|
||||
{
|
||||
const char applications[] = "/applications";
|
||||
char * apppath;
|
||||
|
||||
if((apppath = string_new_append(path, applications, NULL)) == NULL)
|
||||
desktop_serror(NULL, path, 1);
|
||||
callback(handler, path, apppath);
|
||||
string_delete(apppath);
|
||||
}
|
||||
|
||||
static gint _applications_apps_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
MimeApp const * maa = a;
|
||||
MimeApp const * mab = b;
|
||||
|
||||
return mimeapp_compare(maa, mab);
|
||||
}
|
@ -1,435 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* FIXME:
|
||||
* - the initial list has duplicates */
|
||||
|
||||
|
||||
|
||||
#include "mimeapp.h"
|
||||
|
||||
|
||||
/* DesktopHandlerCategories */
|
||||
/* private */
|
||||
/* variables */
|
||||
static DesktopCategory _desktop_categories[] =
|
||||
{
|
||||
{ FALSE, "Audio", N_("Audio"), "gnome-mime-audio", },
|
||||
{ FALSE, "Development", N_("Development"),"applications-development"},
|
||||
{ FALSE, "Education", N_("Education"),"applications-science" },
|
||||
{ FALSE, "Game", N_("Games"), "applications-games" },
|
||||
{ FALSE, "Graphics", N_("Graphics"), "applications-graphics" },
|
||||
{ FALSE, "AudioVideo", N_("Multimedia"),"applications-multimedia"},
|
||||
{ FALSE, "Network", N_("Network"), "applications-internet" },
|
||||
{ FALSE, "Office", N_("Office"), "applications-office" },
|
||||
{ FALSE, "Settings", N_("Settings"), "gnome-settings" },
|
||||
{ FALSE, "System", N_("System"), "applications-system" },
|
||||
{ FALSE, "Utility", N_("Utilities"),"applications-utilities"},
|
||||
{ FALSE, "Video", N_("Video"), "video" }
|
||||
};
|
||||
static const size_t _desktop_categories_cnt = sizeof(_desktop_categories)
|
||||
/ sizeof(*_desktop_categories);
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static void _desktophandler_categories_init(DesktopHandler * handler);
|
||||
static void _desktophandler_categories_destroy(DesktopHandler * handler);
|
||||
static void _desktophandler_categories_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev);
|
||||
static void _desktophandler_categories_refresh(DesktopHandler * handler);
|
||||
|
||||
|
||||
/* functions */
|
||||
/* desktophandler_categories_init */
|
||||
static void _categories_init_on_back(Desktop * desktop, gpointer data);
|
||||
|
||||
static void _desktophandler_categories_init(DesktopHandler * handler)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
GdkPixbuf * icon;
|
||||
unsigned int size;
|
||||
|
||||
handler->u.categories.refresh_dir = NULL;
|
||||
handler->u.categories.refresh_mtime = 0;
|
||||
handler->u.categories.refresh_source = 0;
|
||||
handler->u.categories.apps = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_HORIZONTAL);
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Back"), NULL))
|
||||
== NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, _("Back"), 1);
|
||||
return;
|
||||
}
|
||||
desktopicon_set_callback(desktopicon, _categories_init_on_back, NULL);
|
||||
desktopicon_set_first(desktopicon, TRUE);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
desktop_get_icon_size(handler->desktop, NULL, NULL, &size);
|
||||
icon = gtk_icon_theme_load_icon(desktop_get_theme(handler->desktop),
|
||||
"back", size, 0, NULL);
|
||||
if(icon != NULL)
|
||||
desktopicon_set_icon(desktopicon, icon);
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
}
|
||||
|
||||
static void _categories_init_on_back(Desktop * desktop, gpointer data)
|
||||
{
|
||||
(void) data;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
desktop_set_icons(desktop, DESKTOP_ICONS_HOMESCREEN);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_categories_destroy */
|
||||
static void _desktophandler_categories_destroy(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.categories.refresh_source != 0)
|
||||
g_source_remove(handler->u.categories.refresh_source);
|
||||
if(handler->u.categories.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.categories.refresh_dir);
|
||||
g_slist_foreach(handler->u.categories.apps, (GFunc)mimeapp_delete,
|
||||
NULL);
|
||||
g_slist_free(handler->u.categories.apps);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_categories_popup */
|
||||
static void _desktophandler_categories_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev)
|
||||
{
|
||||
(void) handler;
|
||||
(void) xbev;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_categories_refresh */
|
||||
static gboolean _desktophandler_categories_on_refresh(gpointer data);
|
||||
static gboolean _categories_on_refresh_done(DesktopHandler * handler);
|
||||
static void _categories_on_refresh_done_categories(DesktopHandler * handler);
|
||||
static void _categories_on_refresh_done_categories_open(Desktop * desktop,
|
||||
gpointer data);
|
||||
static int _categories_on_refresh_loop(DesktopHandler * handler);
|
||||
static void _categories_on_refresh_loop_path(DesktopHandler * handler,
|
||||
char const * path, char const * apppath);
|
||||
static void _categories_on_refresh_loop_xdg(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath));
|
||||
static void _categories_on_refresh_loop_xdg_home(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath));
|
||||
static void _categories_on_refresh_loop_xdg_path(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath), char const * path);
|
||||
static gint _categories_apps_compare(gconstpointer a, gconstpointer b);
|
||||
|
||||
static void _desktophandler_categories_refresh(DesktopHandler * handler)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < _desktop_categories_cnt; i++)
|
||||
_desktop_categories[i].show = FALSE;
|
||||
g_slist_foreach(handler->u.categories.apps, (GFunc)mimeapp_delete,
|
||||
NULL);
|
||||
g_slist_free(handler->u.categories.apps);
|
||||
handler->u.categories.apps = NULL;
|
||||
handler->u.categories.refresh_source = g_idle_add(
|
||||
_desktophandler_categories_on_refresh, handler);
|
||||
}
|
||||
|
||||
static gboolean _desktophandler_categories_on_refresh(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
unsigned int i;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
/* FIXME upon deletion one icon too many is removed */
|
||||
for(i = 0; i < IDLE_LOOP_ICON_CNT
|
||||
&& _categories_on_refresh_loop(handler) == 0; i++);
|
||||
if(i == IDLE_LOOP_ICON_CNT)
|
||||
return TRUE;
|
||||
return _categories_on_refresh_done(handler);
|
||||
}
|
||||
|
||||
static gboolean _categories_on_refresh_done(DesktopHandler * handler)
|
||||
{
|
||||
handler->u.categories.refresh_source = 0;
|
||||
_categories_on_refresh_done_categories(handler);
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_done_categories(DesktopHandler * handler)
|
||||
{
|
||||
GSList * p;
|
||||
MimeApp * mimeapp;
|
||||
MimeHandler * mime;
|
||||
String const * name;
|
||||
DesktopCategory * dc;
|
||||
String const ** categories;
|
||||
size_t i;
|
||||
size_t j;
|
||||
String const * filename;
|
||||
DesktopIcon * icon;
|
||||
|
||||
for(p = handler->u.categories.apps; p != NULL; p = p->next)
|
||||
{
|
||||
mimeapp = p->data;
|
||||
mime = mimeapp_get_mime(mimeapp);
|
||||
if((name = mimehandler_get_name(mime, 1)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, NULL, 1);
|
||||
continue;
|
||||
}
|
||||
filename = mimehandler_get_filename(mime);
|
||||
if((categories = mimehandler_get_categories(mime)) == NULL
|
||||
|| categories[0] == NULL)
|
||||
{
|
||||
if((icon = desktopicon_new_application(handler->desktop,
|
||||
filename,
|
||||
mimeapp_get_datadir(mimeapp)))
|
||||
!= NULL)
|
||||
desktop_icon_add(handler->desktop, icon, FALSE);
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < _desktop_categories_cnt; i++)
|
||||
{
|
||||
dc = &_desktop_categories[i];
|
||||
for(j = 0; categories[j] != NULL; j++)
|
||||
if(string_compare(categories[j], dc->category)
|
||||
== 0)
|
||||
break;
|
||||
if(categories[j] != NULL)
|
||||
break;
|
||||
}
|
||||
if(i == _desktop_categories_cnt)
|
||||
{
|
||||
if((icon = desktopicon_new_application(handler->desktop,
|
||||
filename,
|
||||
mimeapp_get_datadir(mimeapp)))
|
||||
!= NULL)
|
||||
desktop_icon_add(handler->desktop, icon, FALSE);
|
||||
continue;
|
||||
}
|
||||
if(dc->show == TRUE)
|
||||
continue;
|
||||
dc->show = TRUE;
|
||||
if((icon = desktopicon_new_category(handler->desktop,
|
||||
_(dc->name), dc->icon)) == NULL)
|
||||
continue;
|
||||
desktopicon_set_callback(icon,
|
||||
_categories_on_refresh_done_categories_open,
|
||||
dc);
|
||||
desktop_icon_add(handler->desktop, icon, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_done_categories_open(Desktop * desktop,
|
||||
gpointer data)
|
||||
{
|
||||
DesktopCategory * dc = data;
|
||||
DesktopHandler * handler;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, _(dc->name));
|
||||
#endif
|
||||
handler = desktop_get_handler(desktop);
|
||||
desktophandler_set_icons(handler, DESKTOP_ICONS_APPLICATIONS);
|
||||
/* FIXME really need an extra argument for applications (category) */
|
||||
handler->u.applications.category = dc;
|
||||
desktop_refresh(desktop);
|
||||
}
|
||||
|
||||
static int _categories_on_refresh_loop(DesktopHandler * handler)
|
||||
{
|
||||
_categories_on_refresh_loop_xdg(handler,
|
||||
_categories_on_refresh_loop_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_loop_path(DesktopHandler * handler,
|
||||
char const * path, char const * apppath)
|
||||
{
|
||||
DIR * dir;
|
||||
struct stat st;
|
||||
size_t alen;
|
||||
struct dirent * de;
|
||||
size_t len;
|
||||
const char ext[] = ".desktop";
|
||||
char * name = NULL;
|
||||
char * p;
|
||||
MimeHandler * mime;
|
||||
MimeApp * mimeapp;
|
||||
|
||||
if((dir = browser_vfs_opendir(apppath, &st)) == NULL)
|
||||
{
|
||||
if(errno != ENOENT)
|
||||
desktop_perror(NULL, apppath, 1);
|
||||
return;
|
||||
}
|
||||
if(st.st_mtime > handler->u.categories.refresh_mtime)
|
||||
handler->u.categories.refresh_mtime = st.st_mtime;
|
||||
alen = strlen(apppath);
|
||||
while((de = browser_vfs_readdir(dir)) != NULL)
|
||||
{
|
||||
if(de->d_name[0] == '.')
|
||||
if(de->d_name[1] == '\0' || (de->d_name[1] == '.'
|
||||
&& de->d_name[2] == '\0'))
|
||||
continue;
|
||||
len = strlen(de->d_name);
|
||||
if(len < sizeof(ext))
|
||||
continue;
|
||||
if(strncmp(&de->d_name[len - sizeof(ext) + 1], ext,
|
||||
sizeof(ext)) != 0)
|
||||
continue;
|
||||
if((p = realloc(name, alen + len + 2)) == NULL)
|
||||
{
|
||||
desktop_perror(NULL, apppath, 1);
|
||||
continue;
|
||||
}
|
||||
name = p;
|
||||
snprintf(name, alen + len + 2, "%s/%s", apppath, de->d_name);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() name=\"%s\" path=\"%s\"\n",
|
||||
__func__, name, path);
|
||||
#endif
|
||||
if((mime = mimehandler_new_load(name)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, NULL, 1);
|
||||
continue;
|
||||
}
|
||||
if(mimehandler_can_display(mime) == 0
|
||||
|| mimehandler_can_execute(mime) == 0
|
||||
|| (mimeapp = mimeapp_new(mime, path)) == NULL)
|
||||
{
|
||||
mimehandler_delete(mime);
|
||||
continue;
|
||||
}
|
||||
handler->u.categories.apps = g_slist_insert_sorted(
|
||||
handler->u.categories.apps, mimeapp,
|
||||
_categories_apps_compare);
|
||||
}
|
||||
free(name);
|
||||
browser_vfs_closedir(dir);
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_loop_xdg(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath))
|
||||
{
|
||||
char const * path;
|
||||
char * p;
|
||||
size_t i;
|
||||
size_t j;
|
||||
int datadir = 1;
|
||||
|
||||
/* read through every XDG application folder */
|
||||
if((path = getenv("XDG_DATA_DIRS")) == NULL || strlen(path) == 0)
|
||||
{
|
||||
#if defined(__NetBSD__)
|
||||
/* XXX include the default path for pkgsrc */
|
||||
path = "/usr/pkg/share:" DATADIR ":/usr/share";
|
||||
#else
|
||||
path = "/usr/local/share:" DATADIR ":/usr/share";
|
||||
#endif
|
||||
datadir = 0;
|
||||
}
|
||||
if((p = strdup(path)) == NULL)
|
||||
desktop_perror(NULL, NULL, 1);
|
||||
else
|
||||
for(i = 0, j = 0;; i++)
|
||||
if(p[i] == '\0')
|
||||
{
|
||||
string_rtrim(&p[j], "/");
|
||||
_categories_on_refresh_loop_xdg_path(handler,
|
||||
callback, &p[j]);
|
||||
datadir |= (strcmp(&p[j], DATADIR) == 0);
|
||||
break;
|
||||
}
|
||||
else if(p[i] == ':')
|
||||
{
|
||||
p[i] = '\0';
|
||||
string_rtrim(&p[j], "/");
|
||||
_categories_on_refresh_loop_xdg_path(handler,
|
||||
callback, &p[j]);
|
||||
datadir |= (strcmp(&p[j], DATADIR) == 0);
|
||||
j = i + 1;
|
||||
}
|
||||
free(p);
|
||||
if(datadir == 0)
|
||||
_categories_on_refresh_loop_xdg_path(handler, callback,
|
||||
DATADIR);
|
||||
_categories_on_refresh_loop_xdg_home(handler, callback);
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_loop_xdg_home(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath))
|
||||
{
|
||||
char const fallback[] = ".local/share";
|
||||
char const * path;
|
||||
char const * homedir;
|
||||
String * p;
|
||||
|
||||
/* use $XDG_DATA_HOME if set and not empty */
|
||||
if((path = getenv("XDG_DATA_HOME")) != NULL && strlen(path) > 0)
|
||||
{
|
||||
_categories_on_refresh_loop_xdg_path(handler, callback, path);
|
||||
return;
|
||||
}
|
||||
/* fallback to "$HOME/.local/share" */
|
||||
if((homedir = getenv("HOME")) == NULL)
|
||||
homedir = g_get_home_dir();
|
||||
if((p = string_new_append(homedir, "/", fallback, NULL)) == NULL)
|
||||
{
|
||||
desktop_serror(NULL, homedir, 1);
|
||||
return;
|
||||
}
|
||||
_categories_on_refresh_loop_xdg_path(handler, callback, p);
|
||||
string_delete(p);
|
||||
}
|
||||
|
||||
static void _categories_on_refresh_loop_xdg_path(DesktopHandler * handler,
|
||||
void (*callback)(DesktopHandler * handler, char const * path,
|
||||
char const * apppath), char const * path)
|
||||
{
|
||||
const char applications[] = "/applications";
|
||||
char * apppath;
|
||||
|
||||
if((apppath = string_new_append(path, applications, NULL)) == NULL)
|
||||
desktop_serror(NULL, path, 1);
|
||||
callback(handler, path, apppath);
|
||||
string_delete(apppath);
|
||||
}
|
||||
|
||||
static gint _categories_apps_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
MimeApp const * maa = a;
|
||||
MimeApp const * mab = b;
|
||||
|
||||
return mimeapp_compare(maa, mab);
|
||||
}
|
@ -1,427 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* FIXME:
|
||||
* - remove (links to) application files upon deletion
|
||||
* - fix the popup menu for preferences
|
||||
* - do not let the symlink window be modal */
|
||||
|
||||
|
||||
|
||||
/* DesktopHandlerFiles */
|
||||
/* private */
|
||||
/* prototypes */
|
||||
static void _desktophandler_files_init(DesktopHandler * handler);
|
||||
static void _desktophandler_files_destroy(DesktopHandler * handler);
|
||||
static void _desktophandler_files_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev);
|
||||
static void _desktophandler_files_refresh(DesktopHandler * handler);
|
||||
|
||||
|
||||
/* functions */
|
||||
/* desktophandler_files_init */
|
||||
static int _files_init_add_home(DesktopHandler * handler);
|
||||
|
||||
static void _desktophandler_files_init(DesktopHandler * handler)
|
||||
{
|
||||
char const * path;
|
||||
struct stat st;
|
||||
|
||||
if((path = getenv("XDG_DESKTOP_DIR")) != NULL)
|
||||
handler->u.files.path = string_new(path);
|
||||
else
|
||||
handler->u.files.path = string_new_append(
|
||||
desktop_get_home(handler->desktop), "/",
|
||||
DESKTOP, NULL);
|
||||
handler->u.files.refresh_dir = NULL;
|
||||
handler->u.files.refresh_mtime = 0;
|
||||
handler->u.files.refresh_source = 0;
|
||||
handler->u.files.menu = NULL;
|
||||
desktop_set_alignment(handler->desktop, DESKTOP_ALIGNMENT_VERTICAL);
|
||||
/* FIXME let it be configured again */
|
||||
handler->u.files.show_hidden = FALSE;
|
||||
/* check for errors */
|
||||
if(handler->u.files.path == NULL)
|
||||
{
|
||||
desktop_error(handler->desktop, NULL, error_get(NULL), 1);
|
||||
return;
|
||||
}
|
||||
_files_init_add_home(handler);
|
||||
if(browser_vfs_stat(handler->u.files.path, &st) == 0)
|
||||
{
|
||||
if(!S_ISDIR(st.st_mode))
|
||||
{
|
||||
desktop_error(NULL, handler->u.files.path,
|
||||
strerror(ENOTDIR), 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(errno != ENOENT)
|
||||
desktop_perror(NULL, handler->u.files.path, 1);
|
||||
}
|
||||
|
||||
static int _files_init_add_home(DesktopHandler * handler)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
GdkPixbuf * icon;
|
||||
unsigned int size;
|
||||
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Home"),
|
||||
desktop_get_home(handler->desktop)))
|
||||
== NULL)
|
||||
return -desktop_serror(handler->desktop, _("Home"), 1);
|
||||
desktopicon_set_first(desktopicon, TRUE);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
desktop_get_icon_size(handler->desktop, NULL, NULL, &size);
|
||||
icon = gtk_icon_theme_load_icon(desktop_get_theme(handler->desktop),
|
||||
"gnome-home", size, 0, NULL);
|
||||
if(icon == NULL)
|
||||
icon = gtk_icon_theme_load_icon(desktop_get_theme(
|
||||
handler->desktop), "gnome-fs-home",
|
||||
size, 0, NULL);
|
||||
if(icon != NULL)
|
||||
desktopicon_set_icon(desktopicon, icon);
|
||||
/* XXX report errors */
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_files_destroy */
|
||||
static void _desktophandler_files_destroy(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.files.refresh_source != 0)
|
||||
g_source_remove(handler->u.files.refresh_source);
|
||||
if(handler->u.files.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.files.refresh_dir);
|
||||
if(handler->u.files.menu != NULL)
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_files_popup */
|
||||
static void _on_popup_new_folder(gpointer data);
|
||||
static void _on_popup_new_text_file(gpointer data);
|
||||
static void _on_popup_paste(gpointer data);
|
||||
static void _on_popup_preferences(gpointer data);
|
||||
static void _on_popup_symlink(gpointer data);
|
||||
|
||||
static void _desktophandler_files_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev)
|
||||
{
|
||||
GtkWidget * menuitem;
|
||||
GtkWidget * submenu;
|
||||
GtkWidget * image;
|
||||
|
||||
if((xbev == NULL || xbev->button != 3) && handler->u.files.menu != NULL)
|
||||
{
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
handler->u.files.menu = NULL;
|
||||
}
|
||||
handler->u.files.menu = gtk_menu_new();
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_New"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||
gtk_image_new_from_icon_name("document-new",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
submenu = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(handler->u.files.menu), menuitem);
|
||||
/* submenu for new documents */
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Folder"));
|
||||
image = gtk_image_new_from_icon_name("folder-new", GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_popup_new_folder), handler);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
|
||||
menuitem = gtk_separator_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Symbolic link..."));
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_popup_symlink), handler);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Text file"));
|
||||
image = gtk_image_new_from_icon_name("stock_new-text",
|
||||
GTK_ICON_SIZE_MENU);
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_popup_new_text_file), handler);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
|
||||
/* edition */
|
||||
menuitem = gtk_separator_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(handler->u.files.menu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Paste"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||
gtk_image_new_from_icon_name("edit-paste",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_popup_paste), handler);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(handler->u.files.menu), menuitem);
|
||||
/* preferences */
|
||||
menuitem = gtk_separator_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(handler->u.files.menu), menuitem);
|
||||
menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Preferences"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||
gtk_image_new_from_icon_name("gtk-preferences",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_signal_connect_swapped(menuitem, "activate", G_CALLBACK(
|
||||
_on_popup_preferences), handler);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(handler->u.files.menu), menuitem);
|
||||
gtk_widget_show_all(handler->u.files.menu);
|
||||
gtk_menu_popup(GTK_MENU(handler->u.files.menu), NULL, NULL, NULL, NULL,
|
||||
3, (xbev != NULL)
|
||||
? xbev->time : gtk_get_current_event_time());
|
||||
}
|
||||
|
||||
static void _on_popup_new_folder(gpointer data)
|
||||
{
|
||||
static char const newfolder[] = N_("New folder");
|
||||
DesktopHandler * handler = data;
|
||||
String * path;
|
||||
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
handler->u.files.menu = NULL;
|
||||
if((path = string_new_append(handler->u.files.path, "/", newfolder,
|
||||
NULL)) == NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, newfolder, 0);
|
||||
return;
|
||||
}
|
||||
if(browser_vfs_mkdir(path, 0777) != 0)
|
||||
desktop_perror(handler->desktop, path, 0);
|
||||
string_delete(path);
|
||||
}
|
||||
|
||||
static void _on_popup_new_text_file(gpointer data)
|
||||
{
|
||||
static char const newtext[] = N_("New text file.txt");
|
||||
DesktopHandler * handler = data;
|
||||
String * path;
|
||||
int fd;
|
||||
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
handler->u.files.menu = NULL;
|
||||
if((path = string_new_append(handler->u.files.path, "/", _(newtext),
|
||||
NULL)) == NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, _(newtext), 0);
|
||||
return;
|
||||
}
|
||||
if((fd = creat(path, 0666)) < 0)
|
||||
desktop_perror(handler->desktop, path, 0);
|
||||
else
|
||||
close(fd);
|
||||
string_delete(path);
|
||||
}
|
||||
|
||||
static void _on_popup_paste(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
|
||||
/* FIXME implement */
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
handler->u.files.menu = NULL;
|
||||
}
|
||||
|
||||
static void _on_popup_preferences(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
|
||||
gtk_widget_destroy(handler->u.files.menu);
|
||||
handler->u.files.menu = NULL;
|
||||
desktop_show_preferences(handler->desktop);
|
||||
}
|
||||
|
||||
static void _on_popup_symlink(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
|
||||
if(_common_symlink(desktop_get_window(handler->desktop),
|
||||
handler->u.files.path) != 0)
|
||||
desktop_perror(handler->desktop, handler->u.files.path, 0);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_files_refresh */
|
||||
static gboolean _desktophandler_files_on_refresh(gpointer data);
|
||||
static gboolean _files_on_refresh_done(DesktopHandler * handler);
|
||||
static gboolean _files_on_refresh_done_timeout(gpointer data);
|
||||
static gboolean _files_on_refresh_loop(DesktopHandler * handler);
|
||||
static int _files_on_refresh_loop_lookup(DesktopHandler * handler,
|
||||
char const * name);
|
||||
static int _files_on_refresh_loop_opendir(DesktopHandler * handler);
|
||||
|
||||
static void _desktophandler_files_refresh(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.files.refresh_source != 0)
|
||||
g_source_remove(handler->u.files.refresh_source);
|
||||
if(handler->u.files.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.files.refresh_dir);
|
||||
handler->u.files.refresh_dir = NULL;
|
||||
if(handler->u.files.path == NULL)
|
||||
return;
|
||||
handler->u.files.refresh_source = g_idle_add(
|
||||
_desktophandler_files_on_refresh, handler);
|
||||
}
|
||||
|
||||
static gboolean _desktophandler_files_on_refresh(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
unsigned int i;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
/* FIXME upon deletion one icon too many is removed */
|
||||
for(i = 0; i < IDLE_LOOP_ICON_CNT
|
||||
&& _files_on_refresh_loop(handler) == 0; i++);
|
||||
if(i == IDLE_LOOP_ICON_CNT)
|
||||
return TRUE;
|
||||
return _files_on_refresh_done(handler);
|
||||
}
|
||||
|
||||
static gboolean _files_on_refresh_done(DesktopHandler * handler)
|
||||
{
|
||||
if(handler->u.files.refresh_dir != NULL)
|
||||
browser_vfs_closedir(handler->u.files.refresh_dir);
|
||||
handler->u.files.refresh_dir = NULL;
|
||||
desktop_icons_cleanup(handler->desktop, TRUE);
|
||||
handler->u.files.refresh_source = g_timeout_add(1000,
|
||||
_files_on_refresh_done_timeout, handler);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean _files_on_refresh_done_timeout(gpointer data)
|
||||
{
|
||||
DesktopHandler * handler = data;
|
||||
struct stat st;
|
||||
|
||||
if(handler->u.files.path == NULL)
|
||||
{
|
||||
handler->u.files.refresh_source = 0;
|
||||
return FALSE;
|
||||
}
|
||||
if(browser_vfs_stat(handler->u.files.path, &st) != 0)
|
||||
{
|
||||
handler->u.files.refresh_source = 0;
|
||||
return desktop_perror(NULL, handler->u.files.path, FALSE);
|
||||
}
|
||||
if(st.st_mtime == handler->u.files.refresh_mtime)
|
||||
return TRUE;
|
||||
handler->u.files.refresh_source = 0;
|
||||
desktop_refresh(handler->desktop);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int _files_on_refresh_loop(DesktopHandler * handler)
|
||||
{
|
||||
const char ext[] = ".desktop";
|
||||
struct dirent * de;
|
||||
String * p;
|
||||
size_t len;
|
||||
gchar * q;
|
||||
DesktopIcon * desktopicon;
|
||||
GError * error = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
if(handler->u.files.refresh_dir == NULL
|
||||
&& _files_on_refresh_loop_opendir(handler) != 0)
|
||||
return -1;
|
||||
while((de = browser_vfs_readdir(handler->u.files.refresh_dir)) != NULL)
|
||||
{
|
||||
if(de->d_name[0] == '.')
|
||||
{
|
||||
if(de->d_name[1] == '\0')
|
||||
continue;
|
||||
if(de->d_name[1] == '.' && de->d_name[2] == '\0')
|
||||
continue;
|
||||
if(handler->u.files.show_hidden == 0)
|
||||
continue;
|
||||
}
|
||||
if(_files_on_refresh_loop_lookup(handler, de->d_name) == 1)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if(de == NULL)
|
||||
return -1;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, de->d_name);
|
||||
#endif
|
||||
if((p = string_new_append(handler->u.files.path, "/", de->d_name, NULL))
|
||||
== NULL)
|
||||
return -desktop_serror(handler->desktop, de->d_name, 1);
|
||||
/* detect desktop entries */
|
||||
if((len = strlen(de->d_name)) > sizeof(ext)
|
||||
&& strcmp(&de->d_name[len - sizeof(ext) + 1], ext) == 0)
|
||||
desktopicon = desktopicon_new_application(handler->desktop, p,
|
||||
handler->u.files.path);
|
||||
/* XXX not relative to the current folder */
|
||||
else if((q = g_filename_to_utf8(de->d_name, -1, NULL, NULL, &error))
|
||||
!= NULL)
|
||||
{
|
||||
desktopicon = desktopicon_new(handler->desktop, q, p);
|
||||
g_free(q);
|
||||
}
|
||||
else
|
||||
{
|
||||
desktop_error(NULL, NULL, error->message, 1);
|
||||
g_error_free(error);
|
||||
desktopicon = desktopicon_new(handler->desktop, de->d_name, p);
|
||||
}
|
||||
if(desktopicon != NULL)
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
string_delete(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _files_on_refresh_loop_lookup(DesktopHandler * handler,
|
||||
char const * name)
|
||||
{
|
||||
DesktopIcon * icon;
|
||||
|
||||
if((icon = desktop_icons_lookup(handler->desktop, name)) == NULL)
|
||||
return 0;
|
||||
desktopicon_set_updated(icon, TRUE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _files_on_refresh_loop_opendir(DesktopHandler * handler)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__,
|
||||
handler->u.files.path);
|
||||
#endif
|
||||
if((handler->u.files.refresh_dir = browser_vfs_opendir(
|
||||
handler->u.files.path, &st)) == NULL)
|
||||
{
|
||||
desktop_perror(NULL, handler->u.files.path, 1);
|
||||
handler->u.files.refresh_source = 0;
|
||||
return -1;
|
||||
}
|
||||
handler->u.files.refresh_mtime = st.st_mtime;
|
||||
return 0;
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
/* DesktopHandlerHomescreen */
|
||||
/* private */
|
||||
/* prototypes */
|
||||
static void _desktophandler_homescreen_init(DesktopHandler * handler);
|
||||
static void _desktophandler_homescreen_destroy(DesktopHandler * handler);
|
||||
static void _desktophandler_homescreen_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev);
|
||||
static void _desktophandler_homescreen_refresh(DesktopHandler * handler);
|
||||
|
||||
|
||||
/* functions */
|
||||
/* desktophandler_homescreen_init */
|
||||
static int _homescreen_init_subdir(DesktopHandler * handler,
|
||||
char const * subdir, char const * name);
|
||||
static void _homescreen_init_on_applications(Desktop * desktop, gpointer data);
|
||||
|
||||
static void _desktophandler_homescreen_init(DesktopHandler * handler)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
GdkPixbuf * icon;
|
||||
char const * paths[] =
|
||||
{
|
||||
#ifdef EMBEDDED
|
||||
/* FIXME let this be configurable */
|
||||
"org.defora.phone-contacts",
|
||||
"org.defora.phone-dialer",
|
||||
"org.defora.phone-messages",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
char const ** p;
|
||||
unsigned int size;
|
||||
|
||||
if((desktopicon = desktopicon_new(handler->desktop, _("Applications"),
|
||||
NULL)) == NULL)
|
||||
{
|
||||
desktop_serror(handler->desktop, _("Applications"), 1);
|
||||
return;
|
||||
}
|
||||
desktopicon_set_callback(desktopicon, _homescreen_init_on_applications,
|
||||
NULL);
|
||||
desktopicon_set_immutable(desktopicon, TRUE);
|
||||
desktop_get_icon_size(handler->desktop, NULL, NULL, &size);
|
||||
icon = gtk_icon_theme_load_icon(desktop_get_theme(handler->desktop),
|
||||
"gnome-applications", size, 0, NULL);
|
||||
if(icon != NULL)
|
||||
desktopicon_set_icon(desktopicon, icon);
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
for(p = paths; *p != NULL; p++)
|
||||
_homescreen_init_subdir(handler, DATADIR "/applications", *p);
|
||||
}
|
||||
|
||||
static int _homescreen_init_subdir(DesktopHandler * handler,
|
||||
char const * subdir, char const * name)
|
||||
{
|
||||
DesktopIcon * desktopicon;
|
||||
String * q;
|
||||
|
||||
if((q = string_new_append(subdir, "/", name, ".desktop", NULL)) == NULL)
|
||||
return -desktop_error(NULL, name, error_get(NULL), 1);
|
||||
if(access(q, R_OK) == 0
|
||||
&& (desktopicon = desktopicon_new_application(
|
||||
handler->desktop, q, DATADIR)) != NULL)
|
||||
desktop_icon_add(handler->desktop, desktopicon, FALSE);
|
||||
string_delete(q);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _homescreen_init_on_applications(Desktop * desktop, gpointer data)
|
||||
{
|
||||
(void) data;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
desktop_set_icons(desktop, DESKTOP_ICONS_CATEGORIES);
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_homescreen_destroy */
|
||||
static void _desktophandler_homescreen_destroy(DesktopHandler * handler)
|
||||
{
|
||||
(void) handler;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_homescreen_popup */
|
||||
static void _desktophandler_homescreen_popup(DesktopHandler * handler,
|
||||
XButtonEvent * xbev)
|
||||
{
|
||||
(void) handler;
|
||||
(void) xbev;
|
||||
}
|
||||
|
||||
|
||||
/* desktophandler_homescreen_refresh */
|
||||
static void _desktophandler_homescreen_refresh(DesktopHandler * handler)
|
||||
{
|
||||
(void) handler;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include "mimeapp.h"
|
||||
|
||||
|
||||
/* MimeApp */
|
||||
/* private */
|
||||
/* types */
|
||||
struct _MimeApp
|
||||
{
|
||||
MimeHandler * mime;
|
||||
String * datadir;
|
||||
};
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
/* mimeapp_new */
|
||||
MimeApp * mimeapp_new(MimeHandler * mime, String const * datadir)
|
||||
{
|
||||
MimeApp * mimeapp;
|
||||
|
||||
if((mimeapp = object_new(sizeof(*mimeapp))) == NULL)
|
||||
return NULL;
|
||||
mimeapp->mime = NULL;
|
||||
if(datadir == NULL)
|
||||
mimeapp->datadir = NULL;
|
||||
else if((mimeapp->datadir = string_new(datadir)) == NULL)
|
||||
{
|
||||
mimeapp_delete(mimeapp);
|
||||
return NULL;
|
||||
}
|
||||
mimeapp->mime = mime;
|
||||
return mimeapp;
|
||||
}
|
||||
|
||||
|
||||
/* mimeapp_delete */
|
||||
void mimeapp_delete(MimeApp * mimeapp)
|
||||
{
|
||||
if(mimeapp->mime != NULL)
|
||||
mimehandler_delete(mimeapp->mime);
|
||||
string_delete(mimeapp->datadir);
|
||||
object_delete(mimeapp);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* mimeapp_get_mime */
|
||||
MimeHandler * mimeapp_get_mime(MimeApp const * mimeapp)
|
||||
{
|
||||
return mimeapp->mime;
|
||||
}
|
||||
|
||||
|
||||
/* mimeapp_get_datadir */
|
||||
String const * mimeapp_get_datadir(MimeApp const * mimeapp)
|
||||
{
|
||||
return mimeapp->datadir;
|
||||
}
|
||||
|
||||
|
||||
/* mimeapp_compare */
|
||||
int mimeapp_compare(MimeApp const * mime, MimeApp const * to)
|
||||
{
|
||||
MimeHandler * mha;
|
||||
MimeHandler * mhb;
|
||||
String const * mhas;
|
||||
String const * mhbs;
|
||||
|
||||
mha = mimeapp_get_mime(mime);
|
||||
mhb = mimeapp_get_mime(to);
|
||||
if((mhas = mimehandler_get_generic_name(mha, 1)) == NULL)
|
||||
mhas = mimehandler_get_name(mha, 1);
|
||||
if((mhbs = mimehandler_get_generic_name(mhb, 1)) == NULL)
|
||||
mhbs = mimehandler_get_name(mhb, 1);
|
||||
return string_compare(mhas, mhbs);
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#ifndef MIMEAPP_H
|
||||
# define MIMEAPP_H
|
||||
|
||||
# include <System.h>
|
||||
# include <Desktop/mimehandler.h>
|
||||
|
||||
|
||||
/* MimeApp */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _MimeApp MimeApp;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
/* MimeApp */
|
||||
MimeApp * mimeapp_new(MimeHandler * mime, String const * datadir);
|
||||
void mimeapp_delete(MimeApp * mimeapp);
|
||||
|
||||
|
||||
/* accessors */
|
||||
MimeHandler * mimeapp_get_mime(MimeApp const * mimeapp);
|
||||
String const * mimeapp_get_datadir(MimeApp const * mimeapp);
|
||||
|
||||
|
||||
/* useful */
|
||||
int mimeapp_compare(MimeApp const * mime, MimeApp const * to);
|
||||
|
||||
#endif /* !MIMEAPP_H */
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2016-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -25,10 +29,7 @@
|
||||
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -1,49 +1,23 @@
|
||||
targets=desktop,desktopctl,handler/mimeapp.o
|
||||
cppflags_force=-I../../include
|
||||
targets=desktop,desktopctl
|
||||
#cppflags=-D EMBEDDED
|
||||
cflags_force=`pkg-config --cflags libDesktop`
|
||||
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
||||
ldflags=-pie -Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile,desktop.h,desktopicon.h,desktopiconwindow.h,handler.h,handler/applications.c,handler/categories.c,handler/files.c,handler/homescreen.c,handler/mimeapp.h
|
||||
dist=Makefile,desktop.h,desktopicon.h,desktopiconwindow.h
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-I../../include -DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-I../../include -DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-I../../include -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[desktop]
|
||||
type=binary
|
||||
depends=$(OBJDIR)../lib/libBrowser.a,$(OBJDIR)handler/mimeapp.o
|
||||
sources=desktop.c,desktopicon.c,desktopiconwindow.c,handler.c,main.c
|
||||
depends=$(OBJDIR)../lib/libBrowser.a
|
||||
sources=desktop.c,desktopicon.c,desktopiconwindow.c,main.c
|
||||
cflags=`pkg-config --cflags x11 xrandr`
|
||||
ldflags=`pkg-config --libs x11 xrandr` -L$(OBJDIR)../lib -Wl,-rpath,$(PREFIX)/lib -lBrowser $(OBJDIR)handler/mimeapp.o
|
||||
ldflags=`pkg-config --libs x11 xrandr` -L$(OBJDIR)../lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(BINDIR)
|
||||
|
||||
[desktopctl]
|
||||
type=binary
|
||||
sources=desktopctl.c
|
||||
install=$(BINDIR)
|
||||
|
||||
[handler/mimeapp.o]
|
||||
type=object
|
||||
sources=handler/mimeapp.c
|
||||
|
||||
#sources
|
||||
[desktop.c]
|
||||
depends=../common.h,../common.c,desktopicon.h,desktop.h,../../config.h
|
||||
cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||
|
||||
[desktopctl.c]
|
||||
depends=desktop.h,../../config.h
|
||||
|
||||
[desktopicon.c]
|
||||
depends=../common.h,../common.c,desktop.h,desktopicon.h,../../config.h
|
||||
cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||
@ -51,8 +25,13 @@ cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||
[desktopiconwindow.c]
|
||||
depends=../common.h,desktop.h,desktopicon.h,desktopiconwindow.h
|
||||
|
||||
[handler.c]
|
||||
depends=desktop.h,desktopicon.h,desktopiconwindow.h,handler.h,handler/applications.c,handler/categories.c,handler/files.c,handler/homescreen.c,handler/mimeapp.h
|
||||
[desktopctl]
|
||||
type=binary
|
||||
sources=desktopctl.c
|
||||
install=$(BINDIR)
|
||||
|
||||
[desktopctl.c]
|
||||
depends=desktop.h,../../config.h
|
||||
|
||||
[main.c]
|
||||
depends=desktop.h,../../config.h
|
||||
|
@ -1,28 +1,11 @@
|
||||
targets=libBrowser
|
||||
cflags_force=`pkg-config --cflags libDesktop` -fPIC
|
||||
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
||||
ldflags=-Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-DNDEBUG
|
||||
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[libBrowser]
|
||||
type=library
|
||||
sources=vfs.c
|
||||
install=$(LIBDIR)
|
||||
|
||||
#sources
|
||||
[vfs.c]
|
||||
depends=../../include/Browser/vfs.h
|
||||
|
329
src/lib/vfs.c
329
src/lib/vfs.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -22,111 +26,22 @@
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* TODO:
|
||||
* - detect and report errors when (un)mounting */
|
||||
|
||||
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/ucred.h>
|
||||
# include <fstab.h>
|
||||
#elif defined(__NetBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/statvfs.h>
|
||||
# include <fstab.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
# include <fstab.h>
|
||||
#elif defined(__sun)
|
||||
#if defined(__sun)
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef __GNU__ /* XXX hurd portability */
|
||||
# include <sys/mount.h>
|
||||
# if defined(__linux__) || defined(__CYGWIN__)
|
||||
# define unmount(a, b) umount(a)
|
||||
# endif
|
||||
# ifndef unmount
|
||||
# define unmount unmount
|
||||
# endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <errno.h>
|
||||
#include <System/error.h>
|
||||
#include <System/string.h>
|
||||
#include "../../include/Browser/vfs.h"
|
||||
|
||||
#ifndef PROGNAME_EJECT
|
||||
# define PROGNAME_EJECT "eject"
|
||||
#endif
|
||||
#ifndef PROGNAME_MOUNT
|
||||
# define PROGNAME_MOUNT "/sbin/mount"
|
||||
#endif
|
||||
#ifndef PROGNAME_SUDO
|
||||
# define PROGNAME_SUDO "sudo"
|
||||
#endif
|
||||
#ifndef PROGNAME_UMOUNT
|
||||
# define PROGNAME_UMOUNT "/sbin/umount"
|
||||
#endif
|
||||
|
||||
|
||||
/* private */
|
||||
/* types */
|
||||
typedef enum _VFSFlag
|
||||
{
|
||||
VF_MOUNTED = 0x01,
|
||||
VF_NETWORK = 0x02,
|
||||
VF_READONLY = 0x04,
|
||||
VF_REMOVABLE = 0x08,
|
||||
VF_SHARED = 0x10
|
||||
} VFSFlag;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
/* accessors */
|
||||
static String * _browser_vfs_get_device(char const * mountpoint);
|
||||
|
||||
static unsigned int _browser_vfs_get_flags_mountpoint(char const * mountpoint);
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
/* accessors */
|
||||
/* browser_vfs_can_eject */
|
||||
int browser_vfs_can_eject(char const * mountpoint)
|
||||
{
|
||||
unsigned int flags;
|
||||
|
||||
flags = _browser_vfs_get_flags_mountpoint(mountpoint);
|
||||
return ((flags & VF_REMOVABLE) != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_can_mount */
|
||||
int browser_vfs_can_mount(char const * mountpoint)
|
||||
{
|
||||
unsigned int flags;
|
||||
|
||||
flags = _browser_vfs_get_flags_mountpoint(mountpoint);
|
||||
return ((flags & VF_REMOVABLE) != 0
|
||||
&& (flags & VF_MOUNTED) == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_can_unmount */
|
||||
int browser_vfs_can_unmount(char const * mountpoint)
|
||||
{
|
||||
unsigned int flags;
|
||||
|
||||
flags = _browser_vfs_get_flags_mountpoint(mountpoint);
|
||||
return ((flags & VF_REMOVABLE) != 0
|
||||
&& (flags & VF_MOUNTED) != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_is_mountpoint */
|
||||
int browser_vfs_is_mountpoint(struct stat * lst, dev_t parent)
|
||||
{
|
||||
@ -149,35 +64,6 @@ int browser_vfs_closedir(DIR * dir)
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_eject */
|
||||
int browser_vfs_eject(char const * mountpoint)
|
||||
{
|
||||
int ret = 0;
|
||||
char * argv[] = { PROGNAME_EJECT, "--", NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_SEARCH_PATH;
|
||||
GError * error = NULL;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, mountpoint);
|
||||
#endif
|
||||
if(mountpoint == NULL)
|
||||
return error_set_code(-EINVAL, "%s", strerror(EINVAL));
|
||||
if((argv[2] = _browser_vfs_get_device(mountpoint)) == NULL)
|
||||
return error_get_code();
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, argv[2]);
|
||||
#endif
|
||||
if(g_spawn_async(NULL, argv, NULL, flags, NULL, NULL, NULL, &error)
|
||||
!= TRUE)
|
||||
{
|
||||
ret = -error_set_code(1, "%s: %s", mountpoint, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
free(argv[2]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_mime_icon */
|
||||
static GdkPixbuf * _mime_icon_emblem(GdkPixbuf * pixbuf, int size,
|
||||
char const * emblem);
|
||||
@ -276,7 +162,7 @@ static GdkPixbuf * _mime_icon_folder(Mime * mime, char const * filename,
|
||||
char const * icon = NULL;
|
||||
struct stat ls;
|
||||
struct stat ps;
|
||||
gchar * p;
|
||||
char * p;
|
||||
size_t i;
|
||||
struct
|
||||
{
|
||||
@ -302,30 +188,27 @@ static GdkPixbuf * _mime_icon_folder(Mime * mime, char const * filename,
|
||||
if(lst == NULL && browser_vfs_lstat(filename, &ls) == 0)
|
||||
lst = &ls;
|
||||
/* check if the folder is special */
|
||||
p = g_path_get_dirname(filename);
|
||||
if((lst == NULL || !S_ISLNK(lst->st_mode))
|
||||
if((p = strdup(filename)) != NULL
|
||||
&& (lst == NULL || !S_ISLNK(lst->st_mode))
|
||||
&& st != NULL
|
||||
&& browser_vfs_lstat(p, &ps) == 0)
|
||||
&& browser_vfs_lstat(dirname(p), &ps) == 0)
|
||||
{
|
||||
if(st->st_dev != ps.st_dev || st->st_ino == ps.st_ino)
|
||||
icon = "mount-point";
|
||||
else if(_mime_icon_folder_is_home(st))
|
||||
icon = "folder_home";
|
||||
else if(_mime_icon_folder_in_home(&ps))
|
||||
{
|
||||
g_free(p);
|
||||
p = g_path_get_basename(filename);
|
||||
/* check if the folder is special */
|
||||
for(i = 0; i < sizeof(name_icon) / sizeof(*name_icon);
|
||||
i++)
|
||||
if(strcasecmp(p, name_icon[i].name) == 0)
|
||||
if(strcasecmp(basename(p), name_icon[i].name)
|
||||
== 0)
|
||||
{
|
||||
icon = name_icon[i].icon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free(p);
|
||||
free(p);
|
||||
if(icon != NULL)
|
||||
{
|
||||
icontheme = gtk_icon_theme_get_default();
|
||||
@ -387,21 +270,23 @@ char const * browser_vfs_mime_type(Mime * mime, char const * filename,
|
||||
char const * ret = NULL;
|
||||
struct stat st;
|
||||
struct stat pst;
|
||||
String * p = NULL;
|
||||
char * p = NULL;
|
||||
|
||||
if(mode == 0 && filename != NULL
|
||||
&& browser_vfs_lstat(filename, &st) == 0)
|
||||
mode = st.st_mode;
|
||||
if(S_ISDIR(mode))
|
||||
{
|
||||
/* look for mountpoints */
|
||||
if(filename != NULL
|
||||
if(filename != NULL && (p = strdup(filename)) != NULL
|
||||
&& browser_vfs_lstat(filename, &st) == 0
|
||||
&& (p = string_new(filename)) != NULL
|
||||
&& browser_vfs_lstat(dirname(p), &pst) == 0
|
||||
&& (st.st_dev != pst.st_dev
|
||||
|| st.st_ino == pst.st_ino))
|
||||
ret = "inode/mountpoint";
|
||||
else
|
||||
ret = "inode/directory";
|
||||
string_delete(p);
|
||||
free(p);
|
||||
return ret;
|
||||
}
|
||||
else if(S_ISBLK(mode))
|
||||
@ -424,44 +309,6 @@ char const * browser_vfs_mime_type(Mime * mime, char const * filename,
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_mkdir */
|
||||
int browser_vfs_mkdir(char const * path, mode_t mode)
|
||||
{
|
||||
if(mkdir(path, mode) != 0)
|
||||
return error_set_code(-errno, "%s: %s", path, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_mount */
|
||||
int browser_vfs_mount(char const * mountpoint)
|
||||
{
|
||||
int ret = 0;
|
||||
char * argv[] = { PROGNAME_SUDO, "-A", PROGNAME_MOUNT, "--", NULL,
|
||||
NULL };
|
||||
GError * error = NULL;
|
||||
gboolean root;
|
||||
|
||||
if(mountpoint == NULL)
|
||||
return error_set_code(-EINVAL, "%s: %s", mountpoint,
|
||||
strerror(EINVAL));
|
||||
if((argv[4] = strdup(mountpoint)) == NULL)
|
||||
return error_set_code(-errno, "%s: %s", mountpoint,
|
||||
strerror(errno));
|
||||
root = (geteuid() == 0) ? TRUE : FALSE;
|
||||
if(g_spawn_async(NULL, root ? &argv[2] : argv, NULL,
|
||||
root ? 0 : G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, &error) != TRUE)
|
||||
{
|
||||
error_set("%s: %s", mountpoint, error->message);
|
||||
g_error_free(error);
|
||||
ret = -1;
|
||||
}
|
||||
free(argv[4]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_opendir */
|
||||
DIR * browser_vfs_opendir(char const * filename, struct stat * st)
|
||||
{
|
||||
@ -507,141 +354,3 @@ int browser_vfs_stat(char const * filename, struct stat * st)
|
||||
{
|
||||
return stat(filename, st);
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_unmount */
|
||||
int browser_vfs_unmount(char const * mountpoint)
|
||||
{
|
||||
int ret = 0;
|
||||
int res;
|
||||
char * argv[] = { PROGNAME_SUDO, "-A", PROGNAME_UMOUNT, "--", NULL,
|
||||
NULL };
|
||||
GError * error = NULL;
|
||||
gboolean root;
|
||||
|
||||
if(mountpoint == NULL)
|
||||
return error_set_code(-EINVAL, "%s: %s", mountpoint,
|
||||
strerror(EINVAL));
|
||||
#ifdef unmount
|
||||
if((res = unmount(mountpoint, 0)) == 0)
|
||||
return 0;
|
||||
if(errno != EPERM)
|
||||
return error_set_code(-errno, "%s: %s", mountpoint,
|
||||
strerror(errno));
|
||||
#endif
|
||||
if((argv[4] = strdup(mountpoint)) == NULL)
|
||||
return error_set_code(-errno, "%s: %s", mountpoint,
|
||||
strerror(errno));
|
||||
root = (geteuid() == 0) ? TRUE : FALSE;
|
||||
if(g_spawn_async(NULL, root ? &argv[2] : argv, NULL,
|
||||
root ? 0 : G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, &error) != TRUE)
|
||||
{
|
||||
error_set("%s: %s", mountpoint, error->message);
|
||||
g_error_free(error);
|
||||
ret = -1;
|
||||
}
|
||||
free(argv[4]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* browser_vfs_get_device */
|
||||
static String * _browser_vfs_get_device(char const * mountpoint)
|
||||
{
|
||||
#if defined(_PATH_FSTAB)
|
||||
struct fstab * f;
|
||||
#endif
|
||||
#if defined(ST_NOWAIT)
|
||||
struct statvfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
|
||||
if((res = getmntinfo(&mnt, ST_NOWAIT)) > 0)
|
||||
for(i = 0; i < res; i++)
|
||||
if(strcmp(mnt[i].f_mntfromname, mountpoint) == 0)
|
||||
return string_new(mnt[i].f_mntfromname);
|
||||
#elif defined(MNT_NOWAIT)
|
||||
struct statfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
|
||||
if((res = getmntinfo(&mnt, MNT_NOWAIT)) > 0)
|
||||
for(i = 0; i < res; i++)
|
||||
if(strcmp(mnt[i].f_mntfromname, mountpoint) == 0)
|
||||
return string_new(mnt[i].f_mntfromname);
|
||||
#endif
|
||||
#if defined(_PATH_FSTAB)
|
||||
if(setfsent() != 1)
|
||||
return NULL;
|
||||
while((f = getfsent()) != NULL)
|
||||
if(strcmp(f->fs_file, mountpoint) == 0)
|
||||
return string_new(f->fs_spec);
|
||||
#endif
|
||||
error_set_code(1, "%s: %s", mountpoint, "Device not found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* browser_vfs_get_flags_mountpoint */
|
||||
static unsigned int _browser_vfs_get_flags_mountpoint(char const * mountpoint)
|
||||
{
|
||||
unsigned int flags;
|
||||
#if defined(_PATH_FSTAB)
|
||||
struct fstab * f;
|
||||
#endif
|
||||
#if defined(ST_NOWAIT)
|
||||
struct statvfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
|
||||
if((res = getmntinfo(&mnt, ST_NOWAIT)) <= 0)
|
||||
return 0;
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
if(strcmp(mnt[i].f_mntfromname, mountpoint) != 0)
|
||||
continue;
|
||||
flags = VF_MOUNTED;
|
||||
flags |= (mnt[i].f_flag & ST_LOCAL) ? 0 : VF_NETWORK;
|
||||
flags |= (mnt[i].f_flag & (ST_EXRDONLY | ST_EXPORTED))
|
||||
? VF_SHARED : 0;
|
||||
flags |= (mnt[i].f_flag & ST_RDONLY) ? VF_READONLY : 0;
|
||||
return flags;
|
||||
}
|
||||
#elif defined(MNT_NOWAIT)
|
||||
struct statfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
|
||||
if((res = getmntinfo(&mnt, MNT_NOWAIT)) <= 0)
|
||||
return 0;
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
if(strcmp(mnt[i].f_mntonname, mountpoint) != 0)
|
||||
continue;
|
||||
flags = VF_MOUNTED;
|
||||
flags |= (mnt[i].f_flags & MNT_LOCAL) ? 0 : VF_NETWORK;
|
||||
flags |= (mnt[i].f_flags & MNT_RDONLY) ? VF_READONLY : 0;
|
||||
return flags;
|
||||
}
|
||||
#endif
|
||||
#if defined(_PATH_FSTAB)
|
||||
if(setfsent() != 1)
|
||||
return -1;
|
||||
while((f = getfsent()) != NULL)
|
||||
{
|
||||
if(strcmp(f->fs_file, mountpoint) != 0
|
||||
|| strcmp(f->fs_type, "sw") == 0
|
||||
|| strcmp(f->fs_type, "xx") == 0)
|
||||
continue;
|
||||
flags = (strcmp(f->fs_vfstype, "nfs") == 0
|
||||
|| strcmp(f->fs_vfstype, "smbfs") == 0)
|
||||
? VF_NETWORK : 0;
|
||||
flags |= (strcmp(f->fs_type, "ro") == 0) ? VF_READONLY : 0;
|
||||
return flags;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
91
src/move.c
91
src/move.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2007-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2007-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -39,7 +43,6 @@
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
@ -115,11 +118,19 @@ static int _move(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_window_set_title(GTK_WINDOW(move.window), _("Move file(s)"));
|
||||
g_signal_connect(G_OBJECT(move.window), "delete-event", G_CALLBACK(
|
||||
_move_on_closex), NULL);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 4);
|
||||
#endif
|
||||
left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
||||
right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
|
||||
/* current argument */
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_label_new(_("Moving: "));
|
||||
bold = pango_font_description_new();
|
||||
pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
|
||||
@ -147,12 +158,13 @@ static int _move(Prefs * prefs, unsigned int filec, char * filev[])
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
|
||||
/* progress bar */
|
||||
move.progress = gtk_progress_bar_new();
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(move.progress), TRUE);
|
||||
#endif
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(move.progress), "");
|
||||
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(move.progress), " ");
|
||||
gtk_box_pack_start(GTK_BOX(vbox), move.progress, TRUE, TRUE, 0);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||
g_signal_connect_swapped(G_OBJECT(widget), "clicked", G_CALLBACK(
|
||||
_move_on_cancel), NULL);
|
||||
@ -205,7 +217,7 @@ static gboolean _move_idle_first(gpointer data)
|
||||
char const * filename = move->filev[move->filec - 1];
|
||||
struct stat st;
|
||||
|
||||
if(browser_vfs_stat(move->filev[move->filec - 1], &st) != 0)
|
||||
if(stat(move->filev[move->filec - 1], &st) != 0)
|
||||
{
|
||||
if(errno != ENOENT)
|
||||
_move_filename_error(move, filename, 0);
|
||||
@ -234,15 +246,12 @@ static gboolean _move_idle_first(gpointer data)
|
||||
}
|
||||
|
||||
/* move_single */
|
||||
static int _single_dir(Move * move, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_fifo(Move * move, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_dir(Move * move, char const * src, char const * dst);
|
||||
static int _single_fifo(Move * move, char const * src, char const * dst);
|
||||
static int _single_nod(Move * move, char const * src, char const * dst,
|
||||
mode_t mode, dev_t rdev);
|
||||
static int _single_symlink(Move * move, char const * src, char const * dst);
|
||||
static int _single_regular(Move * move, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_regular(Move * move, char const * src, char const * dst);
|
||||
static int _single_p(Move * move, char const * dst, struct stat const * st);
|
||||
|
||||
static int _move_single(Move * move, char const * src, char const * dst)
|
||||
@ -250,10 +259,9 @@ static int _move_single(Move * move, char const * src, char const * dst)
|
||||
int ret;
|
||||
struct stat st;
|
||||
|
||||
if(browser_vfs_lstat(src, &st) != 0 && errno == ENOENT) /* XXX TOCTOU */
|
||||
if(lstat(src, &st) != 0 && errno == ENOENT) /* XXX TOCTOU */
|
||||
return _move_filename_error(move, src, 1);
|
||||
if(*(move->prefs) & PREFS_i
|
||||
&& (browser_vfs_lstat(dst, &st) == 0 || errno != ENOENT)
|
||||
if(*(move->prefs) & PREFS_i && (lstat(dst, &st) == 0 || errno != ENOENT)
|
||||
&& _move_filename_confirm(move, dst) != 1)
|
||||
return 0;
|
||||
if(rename(src, dst) == 0)
|
||||
@ -262,23 +270,23 @@ static int _move_single(Move * move, char const * src, char const * dst)
|
||||
return _move_filename_error(move, src, 1);
|
||||
if(unlink(dst) != 0 && errno != ENOENT)
|
||||
return _move_filename_error(move, dst, 1);
|
||||
if(browser_vfs_lstat(src, &st) != 0)
|
||||
if(lstat(src, &st) != 0)
|
||||
return _move_filename_error(move, dst, 1);
|
||||
if(S_ISDIR(st.st_mode))
|
||||
ret = _single_dir(move, src, dst, st.st_mode & 0777);
|
||||
ret = _single_dir(move, src, dst);
|
||||
else if(S_ISFIFO(st.st_mode))
|
||||
ret = _single_fifo(move, src, dst, st.st_mode & 0666);
|
||||
ret = _single_fifo(move, src, dst);
|
||||
else if(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
|
||||
ret = _single_nod(move, src, dst, st.st_mode, st.st_rdev);
|
||||
else if(S_ISLNK(st.st_mode))
|
||||
ret = _single_symlink(move, src, dst);
|
||||
else if(S_ISREG(st.st_mode))
|
||||
ret = _single_regular(move, src, dst, st.st_mode & 0777);
|
||||
else
|
||||
else if(!S_ISREG(st.st_mode)) /* FIXME not implemented */
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return _move_filename_error(move, src, 1);
|
||||
}
|
||||
else
|
||||
ret = _single_regular(move, src, dst);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
_single_p(move, dst, &st);
|
||||
@ -286,21 +294,18 @@ static int _move_single(Move * move, char const * src, char const * dst)
|
||||
}
|
||||
|
||||
/* single_dir */
|
||||
static int _single_recurse(Move * move, char const * src, char const * dst,
|
||||
mode_t mode);
|
||||
static int _single_recurse(Move * move, char const * src, char const * dst);
|
||||
|
||||
static int _single_dir(Move * move, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_dir(Move * move, char const * src, char const * dst)
|
||||
{
|
||||
if(_single_recurse(move, src, dst, mode) != 0)
|
||||
if(_single_recurse(move, src, dst) != 0)
|
||||
return 1;
|
||||
if(rmdir(src) != 0) /* FIXME probably gonna fail, recurse before */
|
||||
_move_filename_error(move, src, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _single_recurse(Move * move, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_recurse(Move * move, char const * src, char const * dst)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t srclen;
|
||||
@ -311,13 +316,13 @@ static int _single_recurse(Move * move, char const * src, char const * dst,
|
||||
char * sdst = NULL;
|
||||
char * p;
|
||||
|
||||
if(browser_vfs_mkdir(dst, mode) != 0)
|
||||
if(mkdir(dst, 0777) != 0) /* XXX use mode from source? */
|
||||
return _move_filename_error(move, dst, 1);
|
||||
srclen = strlen(src);
|
||||
dstlen = strlen(dst);
|
||||
if((dir = browser_vfs_opendir(src, NULL)) == NULL)
|
||||
if((dir = opendir(src)) == NULL)
|
||||
return _move_filename_error(move, src, 1);
|
||||
while((de = browser_vfs_readdir(dir)) != NULL)
|
||||
while((de = readdir(dir)) != NULL)
|
||||
{
|
||||
if(de->d_name[0] == '.' && (de->d_name[1] == '\0'
|
||||
|| (de->d_name[1] == '.'
|
||||
@ -339,16 +344,15 @@ static int _single_recurse(Move * move, char const * src, char const * dst,
|
||||
sprintf(sdst, "%s/%s", dst, de->d_name);
|
||||
ret |= _move_single(move, ssrc, sdst);
|
||||
}
|
||||
browser_vfs_closedir(dir);
|
||||
closedir(dir);
|
||||
free(ssrc);
|
||||
free(sdst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _single_fifo(Move * move, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_fifo(Move * move, char const * src, char const * dst)
|
||||
{
|
||||
if(mkfifo(dst, mode) != 0)
|
||||
if(mkfifo(dst, 0666) != 0) /* XXX use mode from source? */
|
||||
return _move_filename_error(move, dst, 1);
|
||||
if(unlink(src) != 0)
|
||||
_move_filename_error(move, src, 0);
|
||||
@ -380,24 +384,19 @@ static int _single_symlink(Move * move, char const * src, char const * dst)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _single_regular(Move * move, char const * src, char const * dst,
|
||||
mode_t mode)
|
||||
static int _single_regular(Move * move, char const * src, char const * dst)
|
||||
{
|
||||
int ret = 0;
|
||||
FILE * fsrc;
|
||||
int fd;
|
||||
FILE * fdst;
|
||||
char buf[BUFSIZ];
|
||||
size_t size;
|
||||
|
||||
if((fsrc = fopen(src, "r")) == NULL)
|
||||
return _move_filename_error(move, dst, 1);
|
||||
if((fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0
|
||||
|| (fdst = fdopen(fd, "w")) == NULL)
|
||||
if((fdst = fopen(dst, "w")) == NULL)
|
||||
{
|
||||
ret |= _move_filename_error(move, dst, 1);
|
||||
if(fd >= 0)
|
||||
close(fd);
|
||||
fclose(fsrc);
|
||||
return ret;
|
||||
}
|
||||
@ -422,16 +421,16 @@ static int _single_p(Move * move, char const * dst, struct stat const * st)
|
||||
if(lchown(dst, st->st_uid, st->st_gid) != 0) /* XXX TOCTOU */
|
||||
{
|
||||
_move_filename_error(move, dst, 0);
|
||||
if(lchmod(dst, st->st_mode & ~(S_ISUID | S_ISGID)) != 0)
|
||||
if(chmod(dst, st->st_mode & ~(S_ISUID | S_ISGID)) != 0)
|
||||
_move_filename_error(move, dst, 0);
|
||||
}
|
||||
else if(lchmod(dst, st->st_mode) != 0)
|
||||
else if(chmod(dst, st->st_mode) != 0)
|
||||
_move_filename_error(move, dst, 0);
|
||||
tv[0].tv_sec = st->st_atime;
|
||||
tv[0].tv_usec = 0;
|
||||
tv[1].tv_sec = st->st_mtime;
|
||||
tv[1].tv_usec = 0;
|
||||
if(lutimes(dst, tv) != 0)
|
||||
if(utimes(dst, tv) != 0)
|
||||
_move_filename_error(move, dst, 0);
|
||||
return 0;
|
||||
}
|
||||
|
45
src/open.c
45
src/open.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2006-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2006-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -29,7 +33,6 @@
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <System/error.h>
|
||||
#include <Desktop.h>
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
@ -54,7 +57,6 @@
|
||||
/* prototypes */
|
||||
static int _open(char const * type, char const * action, int filec,
|
||||
char * filev[]);
|
||||
static int _open_detect(int filec, char * filev[]);
|
||||
static int _open_error(char const * message, int ret);
|
||||
|
||||
static int _usage(void);
|
||||
@ -70,7 +72,7 @@ static int _open(char const * type, char const * action, int filec,
|
||||
int ret = 0;
|
||||
|
||||
if((mime = mime_new(NULL)) == NULL)
|
||||
return -1;
|
||||
return 1;
|
||||
for(i = 0; i < filec; i++)
|
||||
{
|
||||
if(type == NULL)
|
||||
@ -83,33 +85,13 @@ static int _open(char const * type, char const * action, int filec,
|
||||
fprintf(stderr, "%s%s%s%s%s", PROGNAME_OPEN ": ", filev[i],
|
||||
_(": Could not perform action \""), action,
|
||||
"\"\n");
|
||||
ret = -1;
|
||||
ret = 1;
|
||||
}
|
||||
mime_delete(mime);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* open_detect */
|
||||
static int _open_detect(int filec, char * filev[])
|
||||
{
|
||||
int ret = 0;
|
||||
Mime * mime;
|
||||
int i;
|
||||
char const * type;
|
||||
|
||||
if((mime = mime_new(NULL)) == NULL)
|
||||
return -1;
|
||||
for(i = 0; i < filec; i++)
|
||||
if((type = mime_type(mime, filev[i])) != NULL)
|
||||
printf("%s: %s\n", filev[i], type);
|
||||
else
|
||||
ret |= error_print(PROGNAME_OPEN);
|
||||
mime_delete(mime);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* open_error */
|
||||
static int _open_error(char const * message, int ret)
|
||||
{
|
||||
@ -123,10 +105,8 @@ static int _open_error(char const * message, int ret)
|
||||
static int _usage(void)
|
||||
{
|
||||
fprintf(stderr, _("Usage: %s [-m mime type][-a action] file...\n"
|
||||
" %s -t file...\n"
|
||||
" -t Detect the type of files\n"
|
||||
" -m MIME type to force (default: auto-detected)\n"
|
||||
" -a action to call (default: \"open\")\n"), PROGNAME_OPEN, PROGNAME_OPEN);
|
||||
" -a action to call (default: \"open\")\n"), PROGNAME_OPEN);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -138,7 +118,6 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
int o;
|
||||
char const * action = "open";
|
||||
int detect = 0;
|
||||
char const * type = NULL;
|
||||
|
||||
if(setlocale(LC_ALL, "") == NULL)
|
||||
@ -146,7 +125,7 @@ int main(int argc, char * argv[])
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
gtk_init(&argc, &argv);
|
||||
while((o = getopt(argc, argv, "a:m:t")) != -1)
|
||||
while((o = getopt(argc, argv, "a:m:")) != -1)
|
||||
switch(o)
|
||||
{
|
||||
case 'a':
|
||||
@ -155,16 +134,10 @@ int main(int argc, char * argv[])
|
||||
case 'm':
|
||||
type = optarg;
|
||||
break;
|
||||
case 't':
|
||||
detect = 1;
|
||||
break;
|
||||
default:
|
||||
return _usage();
|
||||
}
|
||||
if(optind == argc)
|
||||
return _usage();
|
||||
if(detect)
|
||||
return (_open_detect(argc - optind, &argv[optind]) == 0)
|
||||
? 0 : 2;
|
||||
return (_open(type, action, argc - optind, &argv[optind]) == 0) ? 0 : 2;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2014-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2013-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2013-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -570,7 +574,7 @@ static gboolean _common_task_on_io_can_read(GIOChannel * channel,
|
||||
_common_task_message(task, GTK_MESSAGE_ERROR,
|
||||
error->message, 1);
|
||||
g_error_free(error);
|
||||
/* fallthrough */
|
||||
/* fallback */
|
||||
case G_IO_STATUS_EOF:
|
||||
default: /* should not happen... */
|
||||
_common_task_close_channel(task, channel);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -71,7 +75,7 @@ typedef struct _BrowserPlugin
|
||||
|
||||
|
||||
/* constants */
|
||||
#define PROGNAME_CVS "cvs"
|
||||
#define CVS_CVS "cvs"
|
||||
|
||||
|
||||
/* prototypes */
|
||||
@ -734,7 +738,7 @@ static void _cvs_on_add(gpointer data)
|
||||
CVS * cvs = data;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "add", "--", NULL, NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "add", "--", NULL, NULL, NULL };
|
||||
char const * type;
|
||||
|
||||
if(cvs->filename == NULL)
|
||||
@ -790,7 +794,7 @@ static void _cvs_on_annotate(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "annotate", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "annotate", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -810,7 +814,7 @@ static void _cvs_on_checkout(gpointer data)
|
||||
{
|
||||
CVS * cvs = data;
|
||||
struct stat st;
|
||||
char * argv[] = { PROGNAME_CVS, "checkout", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "checkout", "--", NULL, NULL };
|
||||
char * dirname;
|
||||
char * path;
|
||||
char * module;
|
||||
@ -839,7 +843,7 @@ static void _cvs_on_commit(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "commit", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "commit", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -872,7 +876,7 @@ static void _cvs_on_delete(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "delete", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "delete", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -902,7 +906,7 @@ static void _cvs_on_diff(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "diff", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "diff", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -924,7 +928,7 @@ static void _cvs_on_log(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "log", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "log", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -946,7 +950,7 @@ static void _cvs_on_status(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "status", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "status", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
@ -968,7 +972,7 @@ static void _cvs_on_update(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_CVS, "update", "--", NULL, NULL };
|
||||
char * argv[] = { CVS_CVS, "update", "--", NULL, NULL };
|
||||
|
||||
if(cvs->filename == NULL || lstat(cvs->filename, &st) != 0)
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2021 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -361,7 +365,6 @@ static void _dirtree_on_row_activated(GtkTreeView * view, GtkTreePath * path,
|
||||
GtkTreeModel * model = GTK_TREE_MODEL(dirtree->sorted);
|
||||
GtkTreeIter iter;
|
||||
gchar * location;
|
||||
(void) column;
|
||||
|
||||
gtk_tree_view_expand_row(view, path, FALSE);
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
@ -379,8 +382,6 @@ static void _dirtree_on_row_expanded(GtkTreeView * view, GtkTreeIter * iter,
|
||||
GtkTreeModel * model = GTK_TREE_MODEL(dirtree->store);
|
||||
GtkTreeIter child;
|
||||
gchar * p;
|
||||
(void) view;
|
||||
(void) path;
|
||||
|
||||
if(dirtree->expanding == TRUE)
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2021 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -442,7 +446,6 @@ static void _favorites_on_row_activated(GtkTreeView * view, GtkTreePath * path,
|
||||
GtkTreeIter fiter;
|
||||
GtkTreeIter iter;
|
||||
gchar * location;
|
||||
(void) column;
|
||||
|
||||
model = gtk_tree_view_get_model(view);
|
||||
if(gtk_tree_model_get_iter(model, &fiter, path) == FALSE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2012-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2012-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -27,13 +31,13 @@
|
||||
|
||||
|
||||
|
||||
#include <System.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <errno.h>
|
||||
#include <System.h>
|
||||
#define COMMON_PROMPT
|
||||
#include "common.c"
|
||||
|
||||
@ -69,7 +73,7 @@ typedef struct _BrowserPlugin
|
||||
|
||||
|
||||
/* constants */
|
||||
#define PROGNAME_GIT "git"
|
||||
#define GIT_GIT "git"
|
||||
|
||||
|
||||
/* prototypes */
|
||||
@ -79,9 +83,9 @@ static GtkWidget * _git_get_widget(Git * git);
|
||||
static void _git_refresh(Git * git, GList * selection);
|
||||
|
||||
/* accessors */
|
||||
static String * _git_get_base(Git * git, char const * filename);
|
||||
static String * _git_get_head(Git * git, char const * filename);
|
||||
static gboolean _git_is_managed(Git * git, char const * filename);
|
||||
static String * _git_get_base(char const * filename);
|
||||
static String * _git_get_head(char const * filename);
|
||||
static gboolean _git_is_managed(char const * filename);
|
||||
static void _git_set_status(Git * git, char const * status);
|
||||
|
||||
/* useful */
|
||||
@ -180,9 +184,6 @@ static Git * _git_init(BrowserPluginHelper * helper)
|
||||
widget = _init_button(group, GTK_STOCK_FIND, _("View log"),
|
||||
G_CALLBACK(_git_on_log), git);
|
||||
gtk_box_pack_start(GTK_BOX(git->directory), widget, FALSE, TRUE, 0);
|
||||
widget = _init_button(group, GTK_STOCK_ADD, _("Stage"),
|
||||
G_CALLBACK(_git_on_add), git);
|
||||
gtk_box_pack_start(GTK_BOX(git->directory), widget, FALSE, TRUE, 0);
|
||||
widget = _init_button(group, GTK_STOCK_PROPERTIES, _("Status"),
|
||||
G_CALLBACK(_git_on_status), git);
|
||||
gtk_box_pack_start(GTK_BOX(git->directory), widget, FALSE, TRUE, 0);
|
||||
@ -315,7 +316,7 @@ static void _git_refresh(Git * git, GList * selection)
|
||||
gtk_label_set_text(GTK_LABEL(git->name), p);
|
||||
g_free(p);
|
||||
_refresh_hide(git, FALSE);
|
||||
if((head = _git_get_head(git, git->filename)) != NULL)
|
||||
if((head = _git_get_head(git->filename)) != NULL)
|
||||
{
|
||||
_git_set_status(git, head);
|
||||
string_delete(head);
|
||||
@ -335,7 +336,7 @@ static void _refresh_dir(Git * git)
|
||||
if((len = strlen(git->filename)) >= (sizeof(dir) - 1)
|
||||
&& strcmp(&git->filename[len - 4], dir) == 0)
|
||||
git->filename[len - 4] = '\0';
|
||||
if(_git_is_managed(git, git->filename) != TRUE)
|
||||
if(_git_is_managed(git->filename) != TRUE)
|
||||
{
|
||||
_git_set_status(git, _("Not a Git repository"));
|
||||
gtk_widget_show(git->init);
|
||||
@ -370,51 +371,51 @@ static void _refresh_hide(Git * git, gboolean name)
|
||||
|
||||
/* accessors */
|
||||
/* git_get_base */
|
||||
static String * _git_get_base(Git * git, char const * filename)
|
||||
static String * _git_get_base(char const * filename)
|
||||
{
|
||||
String * cur;
|
||||
String * base;
|
||||
String * dir;
|
||||
String * p;
|
||||
struct stat st;
|
||||
int res;
|
||||
(void) git;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
|
||||
#endif
|
||||
cur = g_strdup(filename);
|
||||
while(string_compare(cur, ".") != 0)
|
||||
base = string_new(filename);
|
||||
dir = base;
|
||||
for(; string_compare(dir, ".") != 0; dir = dirname(dir))
|
||||
{
|
||||
if((p = string_new_append(cur, "/.git", NULL)) == NULL)
|
||||
break;
|
||||
if((p = string_new_append(dir, "/.git", NULL)) == NULL)
|
||||
{
|
||||
string_delete(base);
|
||||
return NULL;
|
||||
}
|
||||
res = lstat(p, &st);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\" %d\n", __func__, p, res);
|
||||
#endif
|
||||
if(res == 0)
|
||||
{
|
||||
g_free(cur);
|
||||
string_delete(base);
|
||||
return p;
|
||||
}
|
||||
if(string_compare(cur, "/") == 0)
|
||||
if(string_compare(dir, "/") == 0)
|
||||
break;
|
||||
dir = g_path_get_dirname(cur);
|
||||
g_free(cur);
|
||||
cur = dir;
|
||||
}
|
||||
g_free(cur);
|
||||
string_delete(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* git_get_head */
|
||||
static String * _git_get_head(Git * git, char const * filename)
|
||||
static String * _git_get_head(char const * filename)
|
||||
{
|
||||
String * base;
|
||||
String * p;
|
||||
String * head = NULL;
|
||||
|
||||
if((base = _git_get_base(git, filename)) == NULL)
|
||||
if((base = _git_get_base(filename)) == NULL)
|
||||
return NULL;
|
||||
p = string_new_append(base, "/HEAD", NULL);
|
||||
string_delete(base);
|
||||
@ -428,11 +429,11 @@ static String * _git_get_head(Git * git, char const * filename)
|
||||
|
||||
|
||||
/* git_is_managed */
|
||||
static gboolean _git_is_managed(Git * git, char const * filename)
|
||||
static gboolean _git_is_managed(char const * filename)
|
||||
{
|
||||
String * base;
|
||||
|
||||
if((base = _git_get_base(git, filename)) != NULL)
|
||||
if((base = _git_get_base(filename)) != NULL)
|
||||
{
|
||||
/* FIXME check if this file is managed */
|
||||
string_delete(base);
|
||||
@ -483,7 +484,7 @@ static void _git_on_add(gpointer data)
|
||||
Git * git = data;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "add", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "add", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL)
|
||||
return;
|
||||
@ -505,7 +506,7 @@ static void _git_on_blame(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "blame", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "blame", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -536,7 +537,7 @@ static void _git_on_clone(gpointer data)
|
||||
{
|
||||
Git * git = data;
|
||||
struct stat st;
|
||||
char * argv[] = { PROGNAME_GIT, "clone", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "clone", "--", NULL, NULL };
|
||||
char * dirname;
|
||||
char * p;
|
||||
|
||||
@ -574,7 +575,7 @@ static void _git_on_commit(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "commit", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "commit", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -607,7 +608,7 @@ static void _git_on_diff(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "diff", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "diff", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -651,7 +652,7 @@ static void _git_on_init(gpointer data)
|
||||
Git * git = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
char * argv[] = { PROGNAME_GIT, "init", NULL };
|
||||
char * argv[] = { GIT_GIT, "init", NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -681,7 +682,7 @@ static void _git_on_log(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "log", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "log", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -722,7 +723,7 @@ static void _git_on_pull(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "pull", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "pull", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -744,7 +745,7 @@ static void _git_on_push(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "push", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "push", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -766,7 +767,7 @@ static void _git_on_reset(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "reset", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "reset", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
@ -788,7 +789,7 @@ static void _git_on_status(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_GIT, "status", "--", NULL, NULL };
|
||||
char * argv[] = { GIT_GIT, "status", "--", NULL, NULL };
|
||||
|
||||
if(git->filename == NULL || lstat(git->filename, &st) != 0)
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2013-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2013-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2021 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -94,8 +98,6 @@ static Places * _places_init(BrowserPluginHelper * helper)
|
||||
_places_on_open_location), places);
|
||||
return places;
|
||||
#else
|
||||
(void) helper;
|
||||
|
||||
error_set("%s: %s", plugin.name, strerror(ENOSYS));
|
||||
return NULL;
|
||||
#endif
|
||||
@ -123,8 +125,6 @@ static void _places_on_open_location(GtkWidget * widget, GObject * location,
|
||||
{
|
||||
Places * places = data;
|
||||
gchar * path;
|
||||
(void) widget;
|
||||
(void) flags;
|
||||
|
||||
if((path = g_file_get_path(G_FILE(location))) == NULL)
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -408,13 +412,8 @@ static void _preview_get_image_size(Preview * preview, gint * width,
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
*width = preview->helper->get_icon_size(preview->helper->browser,
|
||||
BROWSER_VIEW_THUMBNAILS);
|
||||
#else
|
||||
*width = PREVIEW_IMAGE_SIZE_DEFAULT;
|
||||
#endif
|
||||
*height = *width;
|
||||
*height = PREVIEW_IMAGE_SIZE_DEFAULT;
|
||||
if(preview->path != NULL
|
||||
&& (pixbuf = gdk_pixbuf_new_from_file(preview->path,
|
||||
&error)) != NULL)
|
||||
@ -456,14 +455,8 @@ static void _preview_get_widget_size(Preview * preview, gint * width,
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
*width = preview->helper->get_icon_size(
|
||||
preview->helper->browser,
|
||||
BROWSER_VIEW_THUMBNAILS);
|
||||
#else
|
||||
*width = PREVIEW_IMAGE_SIZE_DEFAULT;
|
||||
#endif
|
||||
*height = *width;
|
||||
*height = PREVIEW_IMAGE_SIZE_DEFAULT;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() %dx%d\n", __func__, *width, *height);
|
||||
|
@ -1,141 +1,127 @@
|
||||
targets=backup,cvs,dirtree,favorites,git,make,places,preview,properties,selection,subversion,template,trash,undelete,volumes
|
||||
cppflags_force=-I../../include
|
||||
cppflags_force=-I ../../include
|
||||
cppflags=
|
||||
cflags_force=`pkg-config --cflags libDesktop` -fPIC
|
||||
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop`
|
||||
ldflags=-Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile,common.c
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-DNDEBUG
|
||||
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[backup]
|
||||
type=plugin
|
||||
sources=backup.c
|
||||
|
||||
[backup.c]
|
||||
depends=trash.c,../../include/Browser.h
|
||||
|
||||
[cvs]
|
||||
type=plugin
|
||||
sources=cvs.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[cvs.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[dirtree]
|
||||
type=plugin
|
||||
sources=dirtree.c
|
||||
ldflags=-L$(OBJDIR)../lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[dirtree.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[favorites]
|
||||
type=plugin
|
||||
sources=favorites.c
|
||||
ldflags=-L$(OBJDIR)../lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[favorites.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[git]
|
||||
type=plugin
|
||||
sources=git.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[git.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[make]
|
||||
type=plugin
|
||||
sources=make.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[make.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[places]
|
||||
type=plugin
|
||||
sources=places.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[places.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[preview]
|
||||
type=plugin
|
||||
sources=preview.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[preview.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[properties]
|
||||
type=plugin
|
||||
sources=properties.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[properties.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[selection]
|
||||
type=plugin
|
||||
sources=selection.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[selection.c]
|
||||
depends=../../include/Browser.h,../common.c
|
||||
|
||||
[subversion]
|
||||
type=plugin
|
||||
sources=subversion.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[subversion.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[template]
|
||||
type=plugin
|
||||
sources=template.c
|
||||
|
||||
[template.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[trash]
|
||||
type=plugin
|
||||
sources=trash.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[trash.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[undelete]
|
||||
type=plugin
|
||||
sources=undelete.c
|
||||
|
||||
[volumes]
|
||||
type=plugin
|
||||
sources=volumes.c
|
||||
ldflags=-L$(OBJDIR)../lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
#sources
|
||||
[backup.c]
|
||||
depends=trash.c,../../include/Browser.h
|
||||
|
||||
[cvs.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[dirtree.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[favorites.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[git.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[make.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[places.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[preview.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[properties.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[selection.c]
|
||||
depends=../../include/Browser.h,../common.c
|
||||
|
||||
[subversion.c]
|
||||
depends=common.c,../../include/Browser.h
|
||||
|
||||
[template.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[trash.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[undelete.c]
|
||||
depends=../../include/Browser.h
|
||||
|
||||
[volumes]
|
||||
type=plugin
|
||||
sources=volumes.c
|
||||
install=$(LIBDIR)/Browser/plugins
|
||||
|
||||
[volumes.c]
|
||||
depends=../../include/Browser.h
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -49,8 +53,6 @@ typedef struct _BrowserPlugin
|
||||
{
|
||||
BrowserPluginHelper * helper;
|
||||
|
||||
int iconsize;
|
||||
|
||||
char * filename;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
@ -165,15 +167,6 @@ static Properties * _properties_new(BrowserPluginHelper * helper,
|
||||
if((properties = object_new(sizeof(*properties))) == NULL)
|
||||
return NULL;
|
||||
properties->helper = helper;
|
||||
properties->iconsize = helper->get_icon_size(helper->browser,
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
BROWSER_VIEW_ICONS
|
||||
#else
|
||||
BROWSER_VIEW_DETAILS
|
||||
#endif
|
||||
);
|
||||
if(properties->iconsize < 0)
|
||||
properties->iconsize = 48;
|
||||
properties->filename = NULL;
|
||||
properties->theme = gtk_icon_theme_get_default();
|
||||
properties->group = NULL;
|
||||
@ -402,8 +395,7 @@ static int _properties_error(Properties * properties, char const * message,
|
||||
|
||||
/* properties_do_refresh */
|
||||
static void _refresh_name(GtkWidget * widget, char const * filename);
|
||||
static void _refresh_type(Properties * properties, struct stat * lst,
|
||||
struct stat * st);
|
||||
static void _refresh_type(Properties * properties, struct stat * lst);
|
||||
static void _refresh_mode(GtkWidget ** widget, mode_t mode, gboolean sensitive);
|
||||
static void _refresh_owner(Properties * properties, uid_t uid);
|
||||
static int _refresh_group(Properties * properties, gid_t gid,
|
||||
@ -414,34 +406,29 @@ static void _refresh_apply(GtkWidget * widget, gboolean sensitive);
|
||||
|
||||
static int _properties_do_refresh(Properties * properties)
|
||||
{
|
||||
struct stat lst;
|
||||
struct stat st;
|
||||
gchar * parent;
|
||||
char * parent;
|
||||
gboolean writable;
|
||||
|
||||
if(lstat(properties->filename, &lst) != 0
|
||||
|| stat(properties->filename, &st) != 0)
|
||||
parent = dirname(properties->filename);
|
||||
if(lstat(properties->filename, &st) != 0)
|
||||
return _properties_error(properties, properties->filename, 0)
|
||||
+ 1;
|
||||
parent = g_path_get_dirname(properties->filename);
|
||||
_refresh_name(properties->name, properties->filename);
|
||||
_refresh_type(properties, &lst, &st);
|
||||
properties->uid = lst.st_uid;
|
||||
properties->gid = lst.st_gid;
|
||||
_refresh_type(properties, &st);
|
||||
properties->uid = st.st_uid;
|
||||
properties->gid = st.st_gid;
|
||||
writable = (access(parent, W_OK) == 0) ? TRUE : FALSE;
|
||||
_refresh_mode(&properties->mode[6], (lst.st_mode & 0700) >> 6,
|
||||
writable);
|
||||
_refresh_mode(&properties->mode[3], (lst.st_mode & 0070) >> 3,
|
||||
writable);
|
||||
_refresh_mode(&properties->mode[0], lst.st_mode & 0007, writable);
|
||||
_refresh_owner(properties, lst.st_uid);
|
||||
_refresh_group(properties, lst.st_gid, writable);
|
||||
_refresh_size(properties, lst.st_size);
|
||||
_refresh_time(properties->atime, lst.st_atime);
|
||||
_refresh_time(properties->mtime, lst.st_mtime);
|
||||
_refresh_time(properties->ctime, lst.st_ctime);
|
||||
_refresh_mode(&properties->mode[6], (st.st_mode & 0700) >> 6, writable);
|
||||
_refresh_mode(&properties->mode[3], (st.st_mode & 0070) >> 3, writable);
|
||||
_refresh_mode(&properties->mode[0], st.st_mode & 0007, writable);
|
||||
_refresh_owner(properties, st.st_uid);
|
||||
_refresh_group(properties, st.st_gid, writable);
|
||||
_refresh_size(properties, st.st_size);
|
||||
_refresh_time(properties->atime, st.st_atime);
|
||||
_refresh_time(properties->mtime, st.st_mtime);
|
||||
_refresh_time(properties->ctime, st.st_ctime);
|
||||
_refresh_apply(properties->apply, writable);
|
||||
g_free(parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -454,17 +441,17 @@ static void _refresh_name(GtkWidget * widget, char const * filename)
|
||||
g_free(gfilename);
|
||||
}
|
||||
|
||||
static void _refresh_type(Properties * properties, struct stat * lst,
|
||||
struct stat * st)
|
||||
static void _refresh_type(Properties * properties, struct stat * lst)
|
||||
{
|
||||
BrowserPluginHelper * helper = properties->helper;
|
||||
char const * type = NULL;
|
||||
GdkPixbuf * pixbuf;
|
||||
const int iconsize = 48;
|
||||
|
||||
type = helper->get_type(helper->browser, properties->filename,
|
||||
st->st_mode);
|
||||
lst->st_mode);
|
||||
pixbuf = helper->get_icon(helper->browser, properties->filename, type,
|
||||
lst, NULL, properties->iconsize);
|
||||
lst, NULL, iconsize);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(properties->image), pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
if(type == NULL)
|
||||
@ -560,12 +547,10 @@ static void _refresh_size(Properties * properties, size_t size)
|
||||
unit = _("MB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = _("GB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = _("TB");
|
||||
else
|
||||
{
|
||||
sz /= 1024;
|
||||
unit = _("PB");
|
||||
unit = _("TB");
|
||||
}
|
||||
snprintf(buf, sizeof(buf), format, sz, unit);
|
||||
gtk_label_set_text(GTK_LABEL(properties->size), buf);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2014-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2014-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -196,7 +200,7 @@ static void _selection_refresh(Selection * selection, GList * selected)
|
||||
if(plst != NULL)
|
||||
size += lst.st_size;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%zu selected (%s)", cnt,
|
||||
snprintf(buf, sizeof(buf), "%lu selected (%s)", cnt,
|
||||
_common_size(size));
|
||||
gtk_label_set_text(GTK_LABEL(selection->status), buf);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -27,13 +31,13 @@
|
||||
|
||||
|
||||
|
||||
#include <System.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <errno.h>
|
||||
#include <System.h>
|
||||
#include "common.c"
|
||||
|
||||
|
||||
@ -68,7 +72,7 @@ typedef struct _BrowserPlugin
|
||||
|
||||
|
||||
/* constants */
|
||||
#define PROGNAME_SVN "svn"
|
||||
#define SVN_SVN "svn"
|
||||
|
||||
|
||||
/* prototypes */
|
||||
@ -78,8 +82,7 @@ static GtkWidget * _subversion_get_widget(SVN * svn);
|
||||
static void _subversion_refresh(SVN * svn, GList * selection);
|
||||
|
||||
/* accessors */
|
||||
static String * _subversion_get_base(SVN * svn, char const * filename);
|
||||
static gboolean _subversion_is_managed(SVN * svn, char const * filename);
|
||||
static gboolean _subversion_is_managed(char const * filename);
|
||||
|
||||
/* useful */
|
||||
static int _subversion_add_task(SVN * svn, char const * title,
|
||||
@ -317,7 +320,7 @@ static void _refresh_dir(SVN * svn)
|
||||
}
|
||||
free(p);
|
||||
/* check if it is a newer SVN repository */
|
||||
if(_subversion_is_managed(svn, svn->filename))
|
||||
if(_subversion_is_managed(svn->filename))
|
||||
gtk_widget_show(svn->directory);
|
||||
else
|
||||
_refresh_status(svn, _("Not a Subversion repository"));
|
||||
@ -349,61 +352,46 @@ static void _refresh_status(SVN * svn, char const * status)
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* subversion_get_base */
|
||||
static String * _subversion_get_base(SVN * svn, char const * filename)
|
||||
/* subversion_is_managed */
|
||||
static gboolean _subversion_is_managed(char const * filename)
|
||||
{
|
||||
String * cur;
|
||||
String * dir;
|
||||
char * base = strdup(filename);
|
||||
char * dir = base;
|
||||
String * p;
|
||||
struct stat st;
|
||||
int res;
|
||||
(void) svn;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
|
||||
#endif
|
||||
cur = g_strdup(filename);
|
||||
while(string_compare(cur, ".") != 0)
|
||||
for(; strcmp(dir, ".") != 0; dir = dirname(dir))
|
||||
{
|
||||
if((p = string_new_append(dir, "/.svn", NULL)) == NULL)
|
||||
break;
|
||||
{
|
||||
free(base);
|
||||
return FALSE;
|
||||
}
|
||||
res = lstat(p, &st);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s() \"%s\" %d\n", __func__, p, res);
|
||||
#endif
|
||||
string_delete(p);
|
||||
if(res == 0)
|
||||
{
|
||||
g_free(cur);
|
||||
return p;
|
||||
/* FIXME really implement */
|
||||
free(base);
|
||||
return TRUE;
|
||||
}
|
||||
if(string_compare(dir, "/") == 0)
|
||||
if(strcmp(dir, "/") == 0)
|
||||
break;
|
||||
dir = g_path_get_dirname(cur);
|
||||
g_free(cur);
|
||||
cur = dir;
|
||||
}
|
||||
g_free(cur);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* subversion_is_managed */
|
||||
static gboolean _subversion_is_managed(SVN * svn, char const * filename)
|
||||
{
|
||||
String * base;
|
||||
|
||||
if((base = _subversion_get_base(svn, filename)) != NULL)
|
||||
{
|
||||
/* FIXME check if this file is managed */
|
||||
string_delete(base);
|
||||
return TRUE;
|
||||
}
|
||||
free(base);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* useful */
|
||||
/* subversion_add_task */
|
||||
/* svn_add_task */
|
||||
static int _subversion_add_task(SVN * svn, char const * title,
|
||||
char const * directory, char * argv[])
|
||||
{
|
||||
@ -423,13 +411,13 @@ static int _subversion_add_task(SVN * svn, char const * title,
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* subversion_on_add */
|
||||
/* svn_on_add */
|
||||
static void _subversion_on_add(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "add", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "add", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL)
|
||||
return;
|
||||
@ -449,7 +437,7 @@ static void _subversion_on_blame(gpointer data)
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "blame", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "blame", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
@ -464,14 +452,14 @@ static void _subversion_on_blame(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* subversion_on_commit */
|
||||
/* svn_on_commit */
|
||||
static void _subversion_on_commit(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "commit", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "commit", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
@ -486,14 +474,14 @@ static void _subversion_on_commit(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* subversion_on_diff */
|
||||
/* svn_on_diff */
|
||||
static void _subversion_on_diff(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "diff", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "diff", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
@ -508,14 +496,14 @@ static void _subversion_on_diff(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* subversion_on_log */
|
||||
/* svn_on_log */
|
||||
static void _subversion_on_log(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "log", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "log", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
@ -530,14 +518,14 @@ static void _subversion_on_log(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* subversion_on_status */
|
||||
/* svn_on_status */
|
||||
static void _subversion_on_status(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "status", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "status", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
@ -552,14 +540,14 @@ static void _subversion_on_status(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* subversion_on_update */
|
||||
/* svn_on_update */
|
||||
static void _subversion_on_update(gpointer data)
|
||||
{
|
||||
SVN * svn = data;
|
||||
struct stat st;
|
||||
gchar * dirname;
|
||||
gchar * basename;
|
||||
char * argv[] = { PROGNAME_SVN, "update", "--", NULL, NULL };
|
||||
char * argv[] = { SVN_SVN, "update", "--", NULL, NULL };
|
||||
|
||||
if(svn->filename == NULL || lstat(svn->filename, &st) != 0)
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2013 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -41,7 +45,7 @@ typedef struct _BrowserPlugin
|
||||
|
||||
GtkWidget * widget;
|
||||
|
||||
/* TODO implement */
|
||||
/* FIXME implement */
|
||||
} Template;
|
||||
|
||||
|
||||
@ -76,7 +80,7 @@ static Template * _template_init(BrowserPluginHelper * helper)
|
||||
if((template = object_new(sizeof(*template))) == NULL)
|
||||
return NULL;
|
||||
template->helper = helper;
|
||||
/* TODO implement */
|
||||
/* FIXME implement */
|
||||
template->widget = gtk_label_new("Template");
|
||||
return template;
|
||||
}
|
||||
@ -85,7 +89,7 @@ static Template * _template_init(BrowserPluginHelper * helper)
|
||||
/* template_destroy */
|
||||
static void _template_destroy(Template * template)
|
||||
{
|
||||
/* TODO implement */
|
||||
/* FIXME implement */
|
||||
object_delete(template);
|
||||
}
|
||||
|
||||
@ -100,5 +104,5 @@ static GtkWidget * _template_get_widget(Template * template)
|
||||
/* template_refresh */
|
||||
static void _template_refresh(Template * template, GList * selection)
|
||||
{
|
||||
/* TODO implement */
|
||||
/* FIXME implement */
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2014-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2014 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -319,7 +323,6 @@ static gboolean _trash_confirm(Trash * trash, char const * message)
|
||||
{
|
||||
GtkWidget * dialog;
|
||||
int res;
|
||||
(void) trash;
|
||||
|
||||
/* XXX move to BrowserPluginHelper */
|
||||
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION,
|
||||
@ -373,7 +376,6 @@ static int _delete_path(Trash * trash, GtkTreeModel * model, GtkTreePath * path)
|
||||
gchar * p;
|
||||
char * files;
|
||||
size_t len;
|
||||
(void) trash;
|
||||
|
||||
if(gtk_tree_model_get_iter(model, &iter, path) != TRUE)
|
||||
/* XXX report error */
|
||||
@ -451,7 +453,6 @@ static void _list_add(Trash * trash, Config * config, char const * path,
|
||||
BrowserPluginHelper * helper = trash->helper;
|
||||
size_t len;
|
||||
GtkTreeIter iter;
|
||||
gint iconsize;
|
||||
GdkPixbuf * pixbuf;
|
||||
char * p;
|
||||
char const * q;
|
||||
@ -472,9 +473,7 @@ static void _list_add(Trash * trash, Config * config, char const * path,
|
||||
g_free(p);
|
||||
return;
|
||||
}
|
||||
gtk_icon_size_lookup(GTK_ICON_SIZE_SMALL_TOOLBAR, &iconsize, &iconsize);
|
||||
pixbuf = helper->get_icon(helper->browser, q, NULL, NULL, NULL,
|
||||
iconsize);
|
||||
pixbuf = helper->get_icon(helper->browser, q, NULL, NULL, NULL, 24);
|
||||
if((u = config_get(config, section, DATA_DELETIONDATE)) != NULL
|
||||
&& strptime(u, "%Y-%m-%dT%H:%M:%S", &tm) != NULL)
|
||||
{
|
||||
@ -583,15 +582,12 @@ static void _trash_on_delete(gpointer data)
|
||||
{
|
||||
Trash * trash = data;
|
||||
GtkTreeSelection * treesel;
|
||||
gint cnt;
|
||||
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(trash->view));
|
||||
if((cnt = gtk_tree_selection_count_selected_rows(treesel)) > 0
|
||||
if(gtk_tree_selection_count_selected_rows(treesel) > 0
|
||||
&& _trash_confirm(trash,
|
||||
ngettext("This will delete the file selected.\n"
|
||||
"Do you really want to proceed?",
|
||||
"This will delete the files selected.\n"
|
||||
"Do you really want to proceed?", cnt)))
|
||||
_("This will delete the file(s) selected.\n"
|
||||
"Do you really want to proceed?")))
|
||||
_trash_delete_selection(trash);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2022 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -31,9 +35,7 @@
|
||||
#include <string.h>
|
||||
#include <System.h>
|
||||
#include <libintl.h>
|
||||
#if defined(__APPLE__)
|
||||
# include <errno.h>
|
||||
#elif defined(__linux__)
|
||||
#ifdef __linux__
|
||||
# include <sys/syscall.h>
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
@ -91,7 +93,7 @@ static GtkWidget * _undelete_get_widget(Undelete * undelete);
|
||||
static void _undelete_refresh(Undelete * undelete, GList * selection);
|
||||
|
||||
/* useful */
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
#ifdef __linux__
|
||||
static int getdents(int fd, char * buf, unsigned int count);
|
||||
#endif
|
||||
|
||||
@ -193,17 +195,7 @@ static void _undelete_refresh(Undelete * undelete, GList * selection)
|
||||
|
||||
|
||||
/* useful */
|
||||
#if defined(__APPLE__)
|
||||
static int getdents(int fd, char * buf, unsigned int count)
|
||||
{
|
||||
(void) fd;
|
||||
(void) buf;
|
||||
(void) count;
|
||||
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
#ifdef __linux__
|
||||
static int getdents(int fd, char * buf, unsigned int count)
|
||||
{
|
||||
return syscall(__NR_getdents64, fd, buf, count);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2011-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -26,22 +30,26 @@
|
||||
|
||||
|
||||
#include <System.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#ifndef __GNU__ /* XXX hurd portability */
|
||||
# include <sys/mount.h>
|
||||
# if defined(__linux__) || defined(__CYGWIN__)
|
||||
# define unmount(a, b) umount(a)
|
||||
# endif
|
||||
# ifndef unmount
|
||||
# define unmount unmount
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/ucred.h>
|
||||
# include <fstab.h>
|
||||
#elif defined(__NetBSD__)
|
||||
# include <sys/param.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/statvfs.h>
|
||||
# include <fstab.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
# include <fstab.h>
|
||||
#endif
|
||||
#include "Browser.h"
|
||||
#include "../../config.h"
|
||||
@ -55,13 +63,6 @@
|
||||
# define BINDIR PREFIX "/bin"
|
||||
#endif
|
||||
|
||||
#ifndef PROGNAME_BROWSER
|
||||
# define PROGNAME_BROWSER "browser"
|
||||
#endif
|
||||
#ifndef PROGNAME_PROPERTIES
|
||||
# define PROGNAME_PROPERTIES "properties"
|
||||
#endif
|
||||
|
||||
|
||||
/* Volumes */
|
||||
/* private */
|
||||
@ -87,11 +88,10 @@ enum _VolumesColumn
|
||||
|
||||
typedef enum _VolumesFlag
|
||||
{
|
||||
DF_MOUNTED = 0x01,
|
||||
DF_NETWORK = 0x02,
|
||||
DF_READONLY = 0x04,
|
||||
DF_REMOVABLE = 0x08,
|
||||
DF_SHARED = 0x10
|
||||
DF_NETWORK = 0x1,
|
||||
DF_READONLY = 0x2,
|
||||
DF_REMOVABLE = 0x4,
|
||||
DF_SHARED = 0x8
|
||||
} VolumesFlag;
|
||||
|
||||
typedef enum _VolumesPixbuf
|
||||
@ -108,10 +108,6 @@ typedef struct _BrowserPlugin
|
||||
{
|
||||
BrowserPluginHelper * helper;
|
||||
guint source;
|
||||
GtkWidget * widget;
|
||||
GtkToolItem * tb_mount;
|
||||
GtkToolItem * tb_unmount;
|
||||
GtkToolItem * tb_eject;
|
||||
GtkWidget * window;
|
||||
GtkListStore * store;
|
||||
GtkWidget * view;
|
||||
@ -132,27 +128,17 @@ static void _volumes_refresh(Volumes * volumes, GList * selection);
|
||||
|
||||
/* accessors */
|
||||
static int _volumes_can_eject(unsigned int flags);
|
||||
static int _volumes_can_mount(unsigned int flags);
|
||||
static int _volumes_can_unmount(unsigned int flags);
|
||||
|
||||
/* useful */
|
||||
static int _volumes_eject(Volumes * volumes, char const * mountpoint);
|
||||
static void _volumes_list(Volumes * volumes);
|
||||
static int _volumes_mount(Volumes * volumes, char const * mountpoint);
|
||||
static int _volumes_unmount(Volumes * volumes, char const * mountpoint);
|
||||
|
||||
/* callbacks */
|
||||
static void _volumes_on_eject_selection(gpointer data);
|
||||
static void _volumes_on_mount_selection(gpointer data);
|
||||
static gboolean _volumes_on_timeout(gpointer data);
|
||||
static void _volumes_on_unmount_selection(gpointer data);
|
||||
static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
GdkEventButton * event, gpointer data);
|
||||
static gboolean _volumes_on_view_popup_menu(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_view_row_activated(GtkWidget * widget,
|
||||
GtkTreePath * path, GtkTreeViewColumn * column, gpointer data);
|
||||
static void _volumes_on_view_row_changed(GtkTreeSelection * treesel,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public */
|
||||
@ -173,13 +159,9 @@ BrowserPluginDefinition plugin =
|
||||
/* functions */
|
||||
/* plug-in */
|
||||
/* volumes_init */
|
||||
static int _init_sort(GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b,
|
||||
gpointer data);
|
||||
|
||||
static Volumes * _volumes_init(BrowserPluginHelper * helper)
|
||||
{
|
||||
Volumes * volumes;
|
||||
GtkWidget * widget;
|
||||
GtkCellRenderer * renderer;
|
||||
GtkTreeViewColumn * column;
|
||||
GtkTreeSelection * treesel;
|
||||
@ -192,63 +174,6 @@ static Volumes * _volumes_init(BrowserPluginHelper * helper)
|
||||
return NULL;
|
||||
volumes->helper = helper;
|
||||
volumes->source = 0;
|
||||
volumes->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||
widget = gtk_toolbar_new();
|
||||
/* mount */
|
||||
#if GTK_CHECK_VERSION(2, 8, 0)
|
||||
volumes->tb_mount = gtk_tool_button_new(NULL, _("Mount"));
|
||||
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(volumes->tb_mount),
|
||||
"hdd_unmount");
|
||||
# if GTK_CHECK_VERSION(2, 12, 0)
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET(volumes->tb_mount),
|
||||
_("Mount the volume"));
|
||||
# endif
|
||||
#else
|
||||
volumes->tb_mount = gtk_tool_button_new(gtk_image_new_from_icon_name(
|
||||
"hdd_unmount", GTK_ICON_SIZE_SMALL_TOOLBAR),
|
||||
_("Mount"));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_mount), FALSE);
|
||||
g_signal_connect_swapped(volumes->tb_mount, "clicked", G_CALLBACK(
|
||||
_volumes_on_mount_selection), volumes);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(widget), volumes->tb_mount, -1);
|
||||
/* unmount */
|
||||
#if GTK_CHECK_VERSION(2, 8, 0)
|
||||
volumes->tb_unmount = gtk_tool_button_new(NULL, _("Unmount"));
|
||||
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(volumes->tb_unmount),
|
||||
"hdd_unmount");
|
||||
# if GTK_CHECK_VERSION(2, 12, 0)
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET(volumes->tb_unmount),
|
||||
_("Unmount the volume"));
|
||||
# endif
|
||||
#else
|
||||
volumes->tb_unmount = gtk_tool_button_new(gtk_image_new_from_icon_name(
|
||||
"hdd_unmount", GTK_ICON_SIZE_SMALL_TOOLBAR),
|
||||
_("Unmount"));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_unmount), FALSE);
|
||||
g_signal_connect_swapped(volumes->tb_unmount, "clicked", G_CALLBACK(
|
||||
_volumes_on_unmount_selection), volumes);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(widget), volumes->tb_unmount, -1);
|
||||
/* eject */
|
||||
#if GTK_CHECK_VERSION(2, 8, 0)
|
||||
volumes->tb_eject = gtk_tool_button_new(NULL, _("Eject"));
|
||||
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(volumes->tb_eject),
|
||||
"media-eject");
|
||||
# if GTK_CHECK_VERSION(2, 12, 0)
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET(volumes->tb_eject),
|
||||
_("Eject the volume"));
|
||||
# endif
|
||||
#else
|
||||
volumes->tb_eject = gtk_tool_button_new(gtk_image_new_from_icon_name(
|
||||
"media-eject", GTK_ICON_SIZE_SMALL_TOOLBAR),
|
||||
_("Eject"));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_eject), FALSE);
|
||||
g_signal_connect_swapped(volumes->tb_eject, "clicked", G_CALLBACK(
|
||||
_volumes_on_eject_selection), volumes);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(widget), volumes->tb_eject, -1);
|
||||
gtk_box_pack_start(GTK_BOX(volumes->widget), widget, FALSE, TRUE, 0);
|
||||
volumes->window = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(volumes->window),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
@ -257,11 +182,6 @@ static Volumes * _volumes_init(BrowserPluginHelper * helper)
|
||||
G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT,
|
||||
G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_STRING,
|
||||
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
|
||||
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(
|
||||
volumes->store), _init_sort, NULL, NULL);
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(volumes->store),
|
||||
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
|
||||
GTK_SORT_ASCENDING);
|
||||
volumes->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||
volumes->store));
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(volumes->view), TRUE);
|
||||
@ -280,72 +200,39 @@ static Volumes * _volumes_init(BrowserPluginHelper * helper)
|
||||
renderer, "text", DC_NAME, "ellipsize", DC_ELLIPSIZE,
|
||||
"ellipsize-set", DC_ELLIPSIZE_SET, NULL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sort_column_id(column, DC_FILESYSTEM);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(volumes->view), column);
|
||||
/* column: size */
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Size"), renderer,
|
||||
"text", DC_SIZE_DISPLAY, NULL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sort_column_id(column, DC_SIZE);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(volumes->view), column);
|
||||
/* column: free space */
|
||||
renderer = gtk_cell_renderer_progress_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Used"), renderer,
|
||||
"text", DC_FREE_DISPLAY, "value", DC_FREE, NULL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sort_column_id(column, DC_FREE);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(volumes->view), column);
|
||||
/* selection */
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(volumes->view));
|
||||
gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect(treesel, "changed", G_CALLBACK(
|
||||
_volumes_on_view_row_changed), volumes);
|
||||
g_signal_connect(volumes->view, "row-activated", G_CALLBACK(
|
||||
_volumes_on_view_row_activated), volumes);
|
||||
gtk_container_add(GTK_CONTAINER(volumes->window), volumes->view);
|
||||
/* icons */
|
||||
icontheme = gtk_icon_theme_get_default();
|
||||
volumes->width = helper->get_icon_size(helper->browser,
|
||||
BROWSER_VIEW_DETAILS);
|
||||
volumes->height = volumes->width;
|
||||
volumes->width = 24;
|
||||
volumes->height = 24;
|
||||
gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &volumes->width,
|
||||
&volumes->height);
|
||||
for(i = 0; i < DP_COUNT; i++)
|
||||
volumes->icons[i] = gtk_icon_theme_load_icon(icontheme,
|
||||
icons[i], volumes->width,
|
||||
GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(volumes->widget), volumes->window, TRUE,
|
||||
TRUE, 0);
|
||||
gtk_widget_show_all(volumes->widget);
|
||||
gtk_widget_show_all(volumes->window);
|
||||
return volumes;
|
||||
}
|
||||
|
||||
static int _init_sort(GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b,
|
||||
gpointer data)
|
||||
{
|
||||
gchar * name_a;
|
||||
gchar * name_b;
|
||||
unsigned int flags_a;
|
||||
unsigned int flags_b;
|
||||
int ret = 0;
|
||||
(void) data;
|
||||
|
||||
gtk_tree_model_get(model, a, DC_MOUNTPOINT, &name_a, DC_FLAGS, &flags_a,
|
||||
-1);
|
||||
gtk_tree_model_get(model, b, DC_MOUNTPOINT, &name_b, DC_FLAGS, &flags_b,
|
||||
-1);
|
||||
if((flags_a & DF_REMOVABLE) != 0 && (flags_b & DF_REMOVABLE) == 0)
|
||||
ret = 1;
|
||||
else if((flags_a & DF_REMOVABLE) == 0 && (flags_b & DF_REMOVABLE) != 0)
|
||||
ret = -1;
|
||||
if(ret == 0)
|
||||
ret = strcmp(name_a, name_b);
|
||||
g_free(name_a);
|
||||
g_free(name_b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* volumes_destroy */
|
||||
static void _volumes_destroy(Volumes * volumes)
|
||||
@ -364,7 +251,7 @@ static void _volumes_destroy(Volumes * volumes)
|
||||
/* volumes_get_widget */
|
||||
static GtkWidget * _volumes_get_widget(Volumes * volumes)
|
||||
{
|
||||
return volumes->widget;
|
||||
return volumes->window;
|
||||
}
|
||||
|
||||
|
||||
@ -400,34 +287,7 @@ static int _volumes_can_eject(unsigned int flags)
|
||||
}
|
||||
|
||||
|
||||
/* volumes_can_mount */
|
||||
static int _volumes_can_mount(unsigned int flags)
|
||||
{
|
||||
return ((flags & DF_REMOVABLE) != 0
|
||||
&& (flags & DF_MOUNTED) == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/* volumes_can_unmount */
|
||||
static int _volumes_can_unmount(unsigned int flags)
|
||||
{
|
||||
return ((flags & DF_REMOVABLE) != 0
|
||||
&& (flags & DF_MOUNTED) != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/* useful */
|
||||
/* volumes_eject */
|
||||
static int _volumes_eject(Volumes * volumes, char const * mountpoint)
|
||||
{
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
|
||||
if(browser_vfs_eject(mountpoint) != 0)
|
||||
return helper->error(helper->browser, error_get(NULL), 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* volumes_list */
|
||||
static void _list_add(Volumes * volumes, char const * name, char const * device,
|
||||
char const * filesystem, unsigned int flags,
|
||||
@ -443,21 +303,61 @@ static GdkPixbuf * _list_get_icon_removable(Volumes * volumes, VolumesPixbuf dp,
|
||||
char const * mountpoint);
|
||||
static void _list_get_iter(Volumes * volumes, GtkTreeIter * iter,
|
||||
char const * mountpoint);
|
||||
static void _list_loop_mounted(Volumes * volumes, int reset);
|
||||
static int _list_loop_unmounted(Volumes * volumes);
|
||||
static void _list_purge(Volumes * volumes);
|
||||
static void _list_reset(Volumes * volumes);
|
||||
|
||||
static void _volumes_list(Volumes * volumes)
|
||||
{
|
||||
#if defined(ST_NOWAIT)
|
||||
struct statvfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
unsigned int flags;
|
||||
#elif defined(MNT_NOWAIT)
|
||||
struct statfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
unsigned int flags;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||
#endif
|
||||
_list_loop_mounted(volumes,
|
||||
_list_loop_unmounted(volumes));
|
||||
#if defined(ST_NOWAIT)
|
||||
if((res = getmntinfo(&mnt, ST_NOWAIT)) <= 0)
|
||||
return;
|
||||
_list_reset(volumes);
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
flags = (mnt[i].f_flag & ST_LOCAL) ? 0 : DF_NETWORK;
|
||||
flags |= (mnt[i].f_flag & (ST_EXRDONLY | ST_EXPORTED))
|
||||
? DF_SHARED : 0;
|
||||
flags |= (mnt[i].f_flag & ST_RDONLY) ? DF_READONLY : 0;
|
||||
_list_add(volumes, (mnt[i].f_flag & ST_ROOTFS)
|
||||
? _("Root filesystem") : NULL,
|
||||
mnt[i].f_mntfromname, mnt[i].f_fstypename,
|
||||
flags, mnt[i].f_mntonname, mnt[i].f_frsize,
|
||||
mnt[i].f_bavail, mnt[i].f_blocks);
|
||||
}
|
||||
#elif defined(MNT_NOWAIT)
|
||||
if((res = getmntinfo(&mnt, MNT_NOWAIT)) <= 0)
|
||||
return;
|
||||
_list_reset(volumes);
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
flags = (mnt[i].f_flags & MNT_LOCAL) ? 0 : DF_NETWORK;
|
||||
flags |= (mnt[i].f_flags & MNT_RDONLY) ? DF_READONLY : 0;
|
||||
_list_add(volumes, (mnt[i].f_flags & MNT_ROOTFS)
|
||||
? _("Root filesystem") : NULL,
|
||||
mnt[i].f_mntfromname, mnt[i].f_fstypename,
|
||||
flags, mnt[i].f_mntonname, mnt[i].f_bsize,
|
||||
mnt[i].f_bavail, mnt[i].f_blocks);
|
||||
}
|
||||
#else
|
||||
_list_reset(volumes);
|
||||
_list_add(volumes, _("Root filesystem"), NULL, NULL, 0, "/", 0, 0, 0);
|
||||
#endif
|
||||
_list_purge(volumes);
|
||||
_volumes_on_view_row_changed(gtk_tree_view_get_selection(
|
||||
GTK_TREE_VIEW(volumes->view)), volumes);
|
||||
}
|
||||
|
||||
static void _list_add(Volumes * volumes, char const * name, char const * device,
|
||||
@ -470,7 +370,7 @@ static void _list_add(Volumes * volumes, char const * name, char const * device,
|
||||
GdkPixbuf * pixbuf;
|
||||
char const * ignore[] = { "kernfs", "proc", "procfs", "ptyfs" };
|
||||
char const * cdrom[] = { "/dev/cd" };
|
||||
char const * removable[] = { "/dev/ld", "/dev/sd" };
|
||||
char const * removable[] = { "/dev/sd" };
|
||||
size_t i;
|
||||
double fraction = 0.0;
|
||||
unsigned int f = 0;
|
||||
@ -496,7 +396,7 @@ static void _list_add(Volumes * volumes, char const * name, char const * device,
|
||||
dp = DP_CDROM;
|
||||
break;
|
||||
}
|
||||
for(i = 0; i < sizeof(removable) / sizeof(*removable); i++)
|
||||
for(i = 0; i < sizeof(removable) / sizeof(removable); i++)
|
||||
if(strncmp(removable[i], device, strlen(removable[i]))
|
||||
== 0)
|
||||
{
|
||||
@ -519,10 +419,7 @@ static void _list_add(Volumes * volumes, char const * name, char const * device,
|
||||
f = fraction * 100;
|
||||
snprintf(buf, sizeof(buf), "%.1f%%", fraction * 100.0);
|
||||
}
|
||||
if(bsize > 0)
|
||||
_list_add_size(buf2, sizeof(buf2), bsize, total);
|
||||
else
|
||||
buf2[0] = '\0';
|
||||
_list_add_size(buf2, sizeof(buf2), bsize, total);
|
||||
_list_get_iter(volumes, &iter, mountpoint);
|
||||
pixbuf = _list_get_icon(volumes, dp, flags, mountpoint);
|
||||
gtk_list_store_set(volumes->store, &iter, DC_DEVICE, device,
|
||||
@ -549,12 +446,10 @@ static void _list_add_size(char * buf, size_t len, unsigned long bsize,
|
||||
unit = _("MB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = _("GB");
|
||||
else if((sz /= 1024) < 1024)
|
||||
unit = _("TB");
|
||||
else
|
||||
{
|
||||
sz /= 1024;
|
||||
unit = _("PB");
|
||||
unit = _("TB");
|
||||
}
|
||||
snprintf(buf, len, format, sz, unit);
|
||||
}
|
||||
@ -680,95 +575,6 @@ static void _list_get_iter(Volumes * volumes, GtkTreeIter * iter,
|
||||
gtk_list_store_append(volumes->store, iter);
|
||||
}
|
||||
|
||||
static void _list_loop_mounted(Volumes * volumes, int reset)
|
||||
{
|
||||
#if defined(ST_NOWAIT)
|
||||
struct statvfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
unsigned int flags;
|
||||
|
||||
if((res = getmntinfo(&mnt, ST_NOWAIT)) <= 0)
|
||||
return;
|
||||
if(reset)
|
||||
_list_reset(volumes);
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
flags = DF_MOUNTED;
|
||||
flags |= (mnt[i].f_flag & ST_LOCAL) ? 0 : DF_NETWORK;
|
||||
flags |= (mnt[i].f_flag & (ST_EXRDONLY | ST_EXPORTED))
|
||||
? DF_SHARED : 0;
|
||||
flags |= (mnt[i].f_flag & ST_RDONLY) ? DF_READONLY : 0;
|
||||
_list_add(volumes, (mnt[i].f_flag & ST_ROOTFS)
|
||||
? _("Root filesystem") : NULL,
|
||||
mnt[i].f_mntfromname, mnt[i].f_fstypename,
|
||||
flags, mnt[i].f_mntonname, mnt[i].f_frsize,
|
||||
mnt[i].f_bavail, mnt[i].f_blocks);
|
||||
}
|
||||
#elif defined(MNT_NOWAIT)
|
||||
struct statfs * mnt;
|
||||
int res;
|
||||
int i;
|
||||
unsigned int flags;
|
||||
|
||||
if((res = getmntinfo(&mnt, MNT_NOWAIT)) <= 0)
|
||||
return;
|
||||
if(reset)
|
||||
_list_reset(volumes);
|
||||
for(i = 0; i < res; i++)
|
||||
{
|
||||
flags = DF_MOUNTED;
|
||||
flags |= (mnt[i].f_flags & MNT_LOCAL) ? 0 : DF_NETWORK;
|
||||
flags |= (mnt[i].f_flags & MNT_RDONLY) ? DF_READONLY : 0;
|
||||
_list_add(volumes, (mnt[i].f_flags & MNT_ROOTFS)
|
||||
? _("Root filesystem") : NULL,
|
||||
mnt[i].f_mntfromname, mnt[i].f_fstypename,
|
||||
flags, mnt[i].f_mntonname, mnt[i].f_bsize,
|
||||
mnt[i].f_bavail, mnt[i].f_blocks);
|
||||
}
|
||||
#else
|
||||
if(reset)
|
||||
_list_reset(volumes);
|
||||
_list_add(volumes, _("Root filesystem"), NULL, NULL, 0, "/", 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int _list_loop_unmounted(Volumes * volumes)
|
||||
{
|
||||
#if defined(_PATH_FSTAB)
|
||||
struct fstab * f;
|
||||
unsigned int flags;
|
||||
|
||||
if(setfsent() != 1)
|
||||
return -1;
|
||||
_list_reset(volumes);
|
||||
while((f = getfsent()) != NULL)
|
||||
{
|
||||
# if defined(FSTAB_SW)
|
||||
if(strcmp(f->fs_type, FSTAB_SW) == 0)
|
||||
continue;
|
||||
# endif
|
||||
# if defined(FSTAB_XX)
|
||||
if(strcmp(f->fs_type, FSTAB_XX) == 0)
|
||||
continue;
|
||||
# endif
|
||||
flags = (strcmp(f->fs_vfstype, "nfs") == 0
|
||||
|| strcmp(f->fs_vfstype, "smbfs") == 0)
|
||||
? DF_NETWORK : 0;
|
||||
flags |= (strcmp(f->fs_type, "ro") == 0) ? DF_READONLY : 0;
|
||||
_list_add(volumes, (strcmp(f->fs_file, "/") == 0)
|
||||
? _("Root filesystem") : NULL,
|
||||
f->fs_spec, f->fs_vfstype,
|
||||
flags, f->fs_file, 0, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
(void) volumes;
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _list_purge(Volumes * volumes)
|
||||
{
|
||||
GtkTreeModel * model = GTK_TREE_MODEL(volumes->store);
|
||||
@ -797,69 +603,7 @@ static void _list_reset(Volumes * volumes)
|
||||
}
|
||||
|
||||
|
||||
/* volumes_mount */
|
||||
static int _volumes_mount(Volumes * volumes, char const * mountpoint)
|
||||
{
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
|
||||
if(browser_vfs_mount(mountpoint) != 0)
|
||||
return helper->error(helper->browser, error_get(NULL), 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* volumes_unmount */
|
||||
static int _volumes_unmount(Volumes * volumes, char const * mountpoint)
|
||||
{
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
|
||||
if(browser_vfs_unmount(mountpoint) != 0)
|
||||
return helper->error(helper->browser, error_get(NULL), 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* volumes_on_eject_selection */
|
||||
static void _volumes_on_eject_selection(gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * device;
|
||||
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(volumes->view));
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, DC_DEVICE, &device, -1);
|
||||
if(device == NULL)
|
||||
return;
|
||||
_volumes_eject(volumes, device);
|
||||
g_free(device);
|
||||
}
|
||||
|
||||
|
||||
/* volumes_on_mount_selection */
|
||||
static void _volumes_on_mount_selection(gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * mountpoint;
|
||||
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(volumes->view));
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, DC_MOUNTPOINT, &mountpoint, -1);
|
||||
if(mountpoint == NULL)
|
||||
return;
|
||||
_volumes_mount(volumes, mountpoint);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
|
||||
/* volumes_on_timeout */
|
||||
static gboolean _volumes_on_timeout(gpointer data)
|
||||
{
|
||||
@ -873,32 +617,9 @@ static gboolean _volumes_on_timeout(gpointer data)
|
||||
}
|
||||
|
||||
|
||||
/* volumes_on_unmount_selection */
|
||||
static void _volumes_on_unmount_selection(gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * mountpoint;
|
||||
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(volumes->view));
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, DC_MOUNTPOINT, &mountpoint, -1);
|
||||
if(mountpoint == NULL)
|
||||
return;
|
||||
_volumes_unmount(volumes, mountpoint);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
|
||||
/* volumes_on_view_button_press */
|
||||
static void _volumes_on_eject(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_open(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_open_new_window(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_properties(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_mount(GtkWidget * widget, gpointer data);
|
||||
static void _volumes_on_unmount(GtkWidget * widget, gpointer data);
|
||||
|
||||
static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
@ -908,6 +629,7 @@ static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
GtkTreeSelection * treesel;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * device;
|
||||
unsigned int flags;
|
||||
gchar * mountpoint;
|
||||
GtkWidget * menu;
|
||||
@ -918,52 +640,20 @@ static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
return FALSE;
|
||||
gtk_tree_model_get(model, &iter, DC_MOUNTPOINT, &mountpoint,
|
||||
DC_FLAGS, &flags, -1);
|
||||
gtk_tree_model_get(model, &iter, DC_DEVICE, &device,
|
||||
DC_MOUNTPOINT, &mountpoint, DC_FLAGS, &flags, -1);
|
||||
if(mountpoint == NULL)
|
||||
return FALSE;
|
||||
menu = gtk_menu_new();
|
||||
/* open */
|
||||
widget = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL);
|
||||
g_object_set_data(G_OBJECT(widget), "mountpoint", mountpoint);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(_volumes_on_open),
|
||||
volumes);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
widget = gtk_image_menu_item_new_with_mnemonic(
|
||||
_("Open in new _window"));
|
||||
/* unmount */
|
||||
widget = gtk_image_menu_item_new_with_label(_("Unmount"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget),
|
||||
gtk_image_new_from_icon_name("window-new",
|
||||
gtk_image_new_from_icon_name("hdd_unmount",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_object_set_data(G_OBJECT(widget), "mountpoint", mountpoint);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(
|
||||
_volumes_on_open_new_window), volumes);
|
||||
_volumes_on_unmount), volumes);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
widget = gtk_separator_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
/* unmount */
|
||||
if(_volumes_can_unmount(flags))
|
||||
{
|
||||
widget = gtk_image_menu_item_new_with_label(_("Unmount"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget),
|
||||
gtk_image_new_from_icon_name("hdd_unmount",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_object_set_data(G_OBJECT(widget), "mountpoint", mountpoint);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(
|
||||
_volumes_on_unmount), volumes);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
}
|
||||
/* mount */
|
||||
else if(_volumes_can_mount(flags))
|
||||
{
|
||||
widget = gtk_image_menu_item_new_with_label(_("Mount"));
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget),
|
||||
gtk_image_new_from_icon_name("hdd_unmount",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_object_set_data(G_OBJECT(widget), "mountpoint", mountpoint);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(
|
||||
_volumes_on_mount), volumes);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
}
|
||||
/* eject */
|
||||
if(_volumes_can_eject(flags))
|
||||
{
|
||||
@ -971,7 +661,7 @@ static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget),
|
||||
gtk_image_new_from_icon_name("media-eject",
|
||||
GTK_ICON_SIZE_MENU));
|
||||
g_object_set_data(G_OBJECT(widget), "mountpoint", mountpoint);
|
||||
g_object_set_data(G_OBJECT(widget), "device", device);
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(
|
||||
_volumes_on_eject), volumes);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), widget);
|
||||
@ -988,6 +678,7 @@ static gboolean _volumes_on_view_button_press(GtkWidget * widget,
|
||||
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button,
|
||||
event->time);
|
||||
#if 0 /* XXX memory leak (for g_object_set_data() above) */
|
||||
g_free(device);
|
||||
g_free(mountpoint);
|
||||
#endif
|
||||
return TRUE;
|
||||
@ -997,56 +688,21 @@ static void _volumes_on_eject(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
|
||||
mountpoint = g_object_get_data(G_OBJECT(widget), "mountpoint");
|
||||
if(_volumes_eject(volumes, mountpoint) != 0)
|
||||
helper->error(helper->browser, error_get(NULL), 1);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
static void _volumes_on_mount(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
|
||||
mountpoint = g_object_get_data(G_OBJECT(widget), "mountpoint");
|
||||
if(_volumes_mount(volumes, mountpoint) != 0)
|
||||
helper->error(helper->browser, error_get(NULL), 1);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
static void _volumes_on_open(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
|
||||
mountpoint = g_object_get_data(G_OBJECT(widget), "mountpoint");
|
||||
helper->set_location(helper->browser, mountpoint);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
static void _volumes_on_open_new_window(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
char * argv[] = { BINDIR "/" PROGNAME_BROWSER, PROGNAME_BROWSER,
|
||||
"--", NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_FILE_AND_ARGV_ZERO;
|
||||
gchar * device;
|
||||
char * argv[] = { "eject", "--", NULL, NULL };
|
||||
const unsigned int flags = G_SPAWN_SEARCH_PATH;
|
||||
GError * error = NULL;
|
||||
|
||||
mountpoint = g_object_get_data(G_OBJECT(widget), "mountpoint");
|
||||
argv[2] = mountpoint;
|
||||
device = g_object_get_data(G_OBJECT(widget), "device");
|
||||
/* FIXME use the device node instead */
|
||||
argv[2] = device;
|
||||
if(g_spawn_async(NULL, argv, NULL, flags, NULL, NULL, NULL, &error)
|
||||
!= TRUE)
|
||||
{
|
||||
helper->error(helper->browser, error->message, 1);
|
||||
g_error_free(error);
|
||||
}
|
||||
g_free(mountpoint);
|
||||
g_free(device);
|
||||
}
|
||||
|
||||
static void _volumes_on_properties(GtkWidget * widget, gpointer data)
|
||||
@ -1054,8 +710,8 @@ static void _volumes_on_properties(GtkWidget * widget, gpointer data)
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
char * argv[] = { BINDIR "/" PROGNAME_PROPERTIES, PROGNAME_PROPERTIES,
|
||||
"--", NULL, NULL };
|
||||
char * argv[] = { BINDIR "/properties", "properties", "--", NULL,
|
||||
NULL };
|
||||
const unsigned int flags = G_SPAWN_FILE_AND_ARGV_ZERO;
|
||||
GError * error = NULL;
|
||||
|
||||
@ -1073,12 +729,16 @@ static void _volumes_on_properties(GtkWidget * widget, gpointer data)
|
||||
static void _volumes_on_unmount(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
gchar * mountpoint;
|
||||
|
||||
mountpoint = g_object_get_data(G_OBJECT(widget), "mountpoint");
|
||||
if(_volumes_unmount(volumes, mountpoint) != 0)
|
||||
helper->error(helper->browser, error_get(NULL), 1);
|
||||
#ifndef unmount
|
||||
errno = ENOSYS;
|
||||
#else
|
||||
if(unmount(mountpoint, 0) != 0)
|
||||
#endif
|
||||
volumes->helper->error(volumes->helper->browser,
|
||||
strerror(errno), 1);
|
||||
g_free(mountpoint);
|
||||
}
|
||||
|
||||
@ -1102,39 +762,14 @@ static void _volumes_on_view_row_activated(GtkWidget * widget,
|
||||
GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
BrowserPluginHelper * helper = volumes->helper;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
gchar * location;
|
||||
(void) column;
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
|
||||
if(gtk_tree_model_get_iter(model, &iter, path) != TRUE)
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, DC_MOUNTPOINT, &location, -1);
|
||||
helper->set_location(helper->browser, location);
|
||||
volumes->helper->set_location(volumes->helper->browser, location);
|
||||
g_free(location);
|
||||
}
|
||||
|
||||
|
||||
/* volumes_on_view_row_changed */
|
||||
static void _volumes_on_view_row_changed(GtkTreeSelection * treesel,
|
||||
gpointer data)
|
||||
{
|
||||
Volumes * volumes = data;
|
||||
GtkTreeModel * model;
|
||||
GtkTreeIter iter;
|
||||
unsigned int flags = 0;
|
||||
gboolean sensitive = TRUE;
|
||||
|
||||
if(gtk_tree_selection_get_selected(treesel, &model, &iter) != TRUE)
|
||||
sensitive = FALSE;
|
||||
else
|
||||
gtk_tree_model_get(model, &iter, DC_FLAGS, &flags, -1);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_mount),
|
||||
sensitive && _volumes_can_mount(flags));
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_unmount),
|
||||
sensitive && _volumes_can_unmount(flags));
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(volumes->tb_eject),
|
||||
sensitive && _volumes_can_eject(flags));
|
||||
}
|
||||
|
@ -1,44 +1,25 @@
|
||||
subdirs=browser,desktop
|
||||
subdirs=lib,browser,desktop
|
||||
targets=copy,delete,move,open,properties,view
|
||||
cppflags_force=-I../include
|
||||
#cppflags=-D EMBEDDED
|
||||
cflags_force=`pkg-config --cflags libDesktop`
|
||||
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
||||
ldflags=-pie -Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile,common.c,common.h
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-I../include -DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-I../include -DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-I../include -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[copy]
|
||||
type=binary
|
||||
sources=copy.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
install=$(BINDIR)
|
||||
|
||||
[delete]
|
||||
type=binary
|
||||
sources=delete.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
install=$(BINDIR)
|
||||
|
||||
[move]
|
||||
type=binary
|
||||
sources=move.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
install=$(BINDIR)
|
||||
|
||||
[open]
|
||||
@ -50,29 +31,19 @@ install=$(BINDIR)
|
||||
type=binary
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
sources=properties.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(BINDIR)
|
||||
|
||||
[view]
|
||||
type=binary
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
sources=view.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(PREFIX)/lib -lBrowser
|
||||
install=$(BINDIR)
|
||||
|
||||
#sources
|
||||
[copy.c]
|
||||
depends=../include/Browser/vfs.h
|
||||
|
||||
[delete.c]
|
||||
depends=../include/Browser/vfs.h
|
||||
|
||||
[move.c]
|
||||
depends=../include/Browser/vfs.h
|
||||
|
||||
[properties.c]
|
||||
depends=../include/Browser.h,browser/browser.h,common.c
|
||||
cppflags=-D PREFIX=\"$(PREFIX)\"
|
||||
|
||||
[view]
|
||||
type=binary
|
||||
depends=$(OBJDIR)lib/libBrowser.a
|
||||
sources=view.c
|
||||
ldflags=-L$(OBJDIR)lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
install=$(BINDIR)
|
||||
|
||||
[view.c]
|
||||
depends=browser/browser.h,common.c
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2007-2024 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2007-2017 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -36,7 +40,7 @@
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "../include/Browser/vfs.h"
|
||||
#define Browser Properties /* XXX */
|
||||
#include "browser/browser.h"
|
||||
#include "../config.h"
|
||||
@ -44,6 +48,7 @@
|
||||
#define N_(string) (string)
|
||||
|
||||
#define COMMON_GET_ABSOLUTE_PATH
|
||||
#define COMMON_CONFIG_FILENAME
|
||||
#include "common.c"
|
||||
|
||||
/* constants */
|
||||
@ -67,7 +72,6 @@
|
||||
struct _Browser
|
||||
{
|
||||
/* internal */
|
||||
Config * config;
|
||||
Mime * mime;
|
||||
char * filename;
|
||||
|
||||
@ -101,11 +105,9 @@ static int _properties_config_set(Properties * properties, char const * section,
|
||||
static GdkPixbuf * _properties_get_icon(Properties * properties,
|
||||
char const * filename, char const * type, struct stat * lst,
|
||||
struct stat * st, int size);
|
||||
static int _properties_get_icon_size(Properties * properties, BrowserView view);
|
||||
static Mime * _properties_get_mime(Properties * properties);
|
||||
static char const * _properties_get_type(Properties * properties,
|
||||
char const * filename, mode_t mode);
|
||||
static BrowserView _properties_get_view(Properties * properties);
|
||||
static int _properties_set_location(Properties * properties,
|
||||
char const * filename);
|
||||
|
||||
@ -167,7 +169,6 @@ static Properties * _properties_new(Mime * mime, char const * plugin,
|
||||
_properties_error(NULL, strerror(errno), 1);
|
||||
return NULL;
|
||||
}
|
||||
properties->config = NULL;
|
||||
properties->mime = mime;
|
||||
properties->filename = strdup(filename);
|
||||
properties->helper.browser = properties;
|
||||
@ -175,10 +176,8 @@ static Properties * _properties_new(Mime * mime, char const * plugin,
|
||||
properties->helper.config_set = _properties_config_set;
|
||||
properties->helper.error = _properties_error;
|
||||
properties->helper.get_icon = _properties_get_icon;
|
||||
properties->helper.get_icon_size = _properties_get_icon_size;
|
||||
properties->helper.get_mime = _properties_get_mime;
|
||||
properties->helper.get_type = _properties_get_type;
|
||||
properties->helper.get_view = _properties_get_view;
|
||||
properties->helper.set_location = _properties_helper_set_location;
|
||||
properties->window = NULL;
|
||||
if(properties->filename == NULL)
|
||||
@ -233,19 +232,19 @@ static Properties * _properties_new(Mime * mime, char const * plugin,
|
||||
|
||||
static int _new_load(Properties * properties, char const * plugin)
|
||||
{
|
||||
Config * config;
|
||||
char const * plugins = NULL;
|
||||
char * p;
|
||||
char * q;
|
||||
size_t i;
|
||||
int cnt = 0;
|
||||
|
||||
if((properties->config = config_new()) != NULL
|
||||
&& config_load_preferences(properties->config,
|
||||
BROWSER_CONFIG_VENDOR, PACKAGE,
|
||||
BROWSER_CONFIG_FILE) == 0
|
||||
&& (plugins = config_get(properties->config, NULL,
|
||||
"properties")) == NULL)
|
||||
p = _common_config_filename(BROWSER_CONFIG_FILE);
|
||||
if((config = config_new()) != NULL && config_load(config, p) == 0
|
||||
&& (plugins = config_get(config, NULL, "properties"))
|
||||
== NULL)
|
||||
plugins = "properties,preview";
|
||||
string_delete(p);
|
||||
if(plugin != NULL)
|
||||
{
|
||||
if(_properties_load(properties, plugin) == 0)
|
||||
@ -280,6 +279,8 @@ static int _new_load(Properties * properties, char const * plugin)
|
||||
if(_properties_load(properties, "preview") == 0)
|
||||
cnt++;
|
||||
}
|
||||
if(config != NULL)
|
||||
config_delete(config);
|
||||
/* consider ourselves successful if at least one plug-in was loaded */
|
||||
return (cnt > 0) ? 0 : -1;
|
||||
}
|
||||
@ -291,8 +292,6 @@ static void _properties_delete(Properties * properties)
|
||||
if(properties->window != NULL)
|
||||
gtk_widget_destroy(properties->window);
|
||||
free(properties->filename);
|
||||
if(properties->config != NULL)
|
||||
config_delete(properties->config);
|
||||
free(properties);
|
||||
_properties_cnt--;
|
||||
}
|
||||
@ -303,9 +302,8 @@ static void _properties_delete(Properties * properties)
|
||||
static char const * _properties_config_get(Properties * properties,
|
||||
char const * section, char const * variable)
|
||||
{
|
||||
if(properties->config == NULL)
|
||||
return NULL;
|
||||
return config_get(properties->config, section, variable);
|
||||
/* FIXME implement */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -313,9 +311,8 @@ static char const * _properties_config_get(Properties * properties,
|
||||
static int _properties_config_set(Properties * properties, char const * section,
|
||||
char const * variable, char const * value)
|
||||
{
|
||||
if(properties->config == NULL)
|
||||
return -1;
|
||||
return config_set(properties->config, section, variable, value);
|
||||
/* FIXME implement */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -329,16 +326,6 @@ static GdkPixbuf * _properties_get_icon(Properties * properties,
|
||||
}
|
||||
|
||||
|
||||
/* properties_get_icon_size */
|
||||
static int _properties_get_icon_size(Properties * properties, BrowserView view)
|
||||
{
|
||||
(void) properties;
|
||||
(void) view;
|
||||
|
||||
return BROWSER_ICON_SIZE_ICONS;
|
||||
}
|
||||
|
||||
|
||||
/* properties_get_mime */
|
||||
static Mime * _properties_get_mime(Properties * properties)
|
||||
{
|
||||
@ -354,15 +341,6 @@ static char const * _properties_get_type(Properties * properties,
|
||||
}
|
||||
|
||||
|
||||
/* properties_get_view */
|
||||
static BrowserView _properties_get_view(Properties * properties)
|
||||
{
|
||||
(void) properties;
|
||||
|
||||
return BROWSER_VIEW_DETAILS;
|
||||
}
|
||||
|
||||
|
||||
/* properties_set_location */
|
||||
static int _properties_set_location(Properties * properties,
|
||||
char const * filename)
|
||||
@ -377,8 +355,7 @@ static int _properties_set_location(Properties * properties,
|
||||
}
|
||||
|
||||
|
||||
/* useful */
|
||||
/* properties_error */
|
||||
/* _properties_error */
|
||||
static void _error_response(GtkWidget * widget, gint arg, gpointer data);
|
||||
static int _error_text(char const * message, int ret);
|
||||
|
||||
@ -415,7 +392,6 @@ static int _properties_error(Properties * properties, char const * message,
|
||||
static void _error_response(GtkWidget * widget, gint arg, gpointer data)
|
||||
{
|
||||
unsigned int * cnt = data;
|
||||
(void) arg;
|
||||
|
||||
if(cnt == NULL)
|
||||
gtk_widget_destroy(widget);
|
||||
@ -467,7 +443,11 @@ static int _properties_load(Properties * properties, char const * name)
|
||||
if(icon == NULL)
|
||||
icon = gtk_icon_theme_load_icon(properties->theme,
|
||||
"gnome-settings", 24, 0, NULL);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
#else
|
||||
hbox = gtk_hbox_new(FALSE, 4);
|
||||
#endif
|
||||
gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(icon),
|
||||
FALSE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_(bpd->name)), TRUE,
|
||||
|
32
src/view.c
32
src/view.c
@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
static char const _copyright[] =
|
||||
"Copyright © 2007-2021 Pierre Pronchery <khorben@defora.org>";
|
||||
"Copyright © 2007-2017 Pierre Pronchery <khorben@defora.org>";
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
static char const _license[] =
|
||||
"Redistribution and use in source and binary forms, with or without\n"
|
||||
@ -14,6 +14,10 @@ static char const _license[] =
|
||||
" this list of conditions and the following disclaimer in the documentation\n"
|
||||
" and/or other materials provided with the distribution.\n"
|
||||
"\n"
|
||||
"3. Neither the name of the authors nor the names of the contributors may be\n"
|
||||
" used to endorse or promote products derived from this software without\n"
|
||||
" specific prior written permission.\n"
|
||||
"\n"
|
||||
"THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS \"AS IS\" AND ANY\n"
|
||||
"EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"
|
||||
"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
|
||||
@ -39,7 +43,7 @@ static char const _license[] =
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#include "Browser/vfs.h"
|
||||
#include "../include/Browser/vfs.h"
|
||||
#define Browser View /* XXX */
|
||||
#include "browser/browser.h"
|
||||
#include "../config.h"
|
||||
@ -148,22 +152,22 @@ static DesktopMenu _view_menu_file[] =
|
||||
{ N_("Open _with..."), G_CALLBACK(_view_on_file_open_with), NULL, 0,
|
||||
0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Close"), G_CALLBACK(_view_on_file_close), "window-close",
|
||||
{ N_("_Close"), G_CALLBACK(_view_on_file_close), GTK_STOCK_CLOSE,
|
||||
GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
static DesktopMenu _view_menu_file_edit[] =
|
||||
{
|
||||
{ N_("_Edit"), G_CALLBACK(_view_on_file_edit), "text-editor",
|
||||
{ N_("_Edit"), G_CALLBACK(_view_on_file_edit), GTK_STOCK_EDIT,
|
||||
GDK_CONTROL_MASK, GDK_KEY_E },
|
||||
{ N_("Open _with..."), G_CALLBACK(_view_on_file_open_with), NULL, 0,
|
||||
0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Properties"), G_CALLBACK(_view_on_file_properties),
|
||||
"document-properties", GDK_MOD1_MASK, GDK_KEY_Return },
|
||||
GTK_STOCK_PROPERTIES, GDK_MOD1_MASK, GDK_KEY_Return },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Close"), G_CALLBACK(_view_on_file_close), "window-close",
|
||||
{ N_("_Close"), G_CALLBACK(_view_on_file_close), GTK_STOCK_CLOSE,
|
||||
GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
@ -172,7 +176,12 @@ static DesktopMenu _view_menu_help[] =
|
||||
{
|
||||
{ N_("Contents"), G_CALLBACK(_view_on_help_contents), "help-contents",
|
||||
0, GDK_KEY_F1 },
|
||||
{ N_("_About"), G_CALLBACK(_view_on_help_about), "help-about", 0, 0 },
|
||||
# if GTK_CHECK_VERSION(2, 6, 0)
|
||||
{ N_("_About"), G_CALLBACK(_view_on_help_about), GTK_STOCK_ABOUT, 0,
|
||||
0 },
|
||||
# else
|
||||
{ N_("_About"), G_CALLBACK(_view_on_help_about), NULL, 0, 0 },
|
||||
# endif
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@ -256,7 +265,11 @@ static View * _view_new(Mime * mime, char const * filename)
|
||||
gtk_window_set_title(GTK_WINDOW(view->window), buf);
|
||||
g_signal_connect_swapped(view->window, "delete-event", G_CALLBACK(
|
||||
_view_on_closex), view);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||
#else
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
#endif
|
||||
#ifndef EMBEDDED
|
||||
widget = desktop_menubar_create(
|
||||
(mime_get_handler(mime, type, "edit") != NULL)
|
||||
@ -349,8 +362,6 @@ static void _view_delete(View * view)
|
||||
static String const * _view_config_get(View * view, String const * section,
|
||||
String const * variable)
|
||||
{
|
||||
(void) view;
|
||||
|
||||
if(section != NULL)
|
||||
{
|
||||
if(strcmp(section, "preview") == 0
|
||||
@ -445,7 +456,6 @@ static int _view_error(View * view, char const * message, int ret)
|
||||
static void _error_response(GtkWidget * widget, gint arg, gpointer data)
|
||||
{
|
||||
View * view = data;
|
||||
(void) arg;
|
||||
|
||||
if(view != NULL)
|
||||
_view_delete(view);
|
||||
@ -598,8 +608,6 @@ static void _view_on_file_close(gpointer data)
|
||||
/* view_on_help_contents */
|
||||
static void _view_on_help_contents(gpointer data)
|
||||
{
|
||||
(void) data;
|
||||
|
||||
desktop_help_contents(PACKAGE, PROGNAME_VIEW);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015-2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -25,4 +29,108 @@
|
||||
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#include "../browser/browser.h"
|
||||
#include "../browser/callbacks.h"
|
||||
|
||||
#include "../browser/browser.c"
|
||||
/* XXX */
|
||||
#undef COMMON_CONFIG_FILENAME
|
||||
#undef COMMON_DND
|
||||
#undef COMMON_EXEC
|
||||
#undef COMMON_GET_ABSOLUTE_PATH
|
||||
#undef COMMON_SIZE
|
||||
#include "../browser/callbacks.c"
|
||||
#include "../browser/window.c"
|
||||
|
||||
|
||||
/* BrowserWidget */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _DesktopWidgetPlugin
|
||||
{
|
||||
Browser * browser;
|
||||
} BrowserWidget;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static BrowserWidget * _browser_init(char const * name);
|
||||
static void _browser_destroy(BrowserWidget * browser);
|
||||
|
||||
static GtkWidget * _browser_get_widget(BrowserWidget * browser);
|
||||
|
||||
static int _browser_set_property(BrowserWidget * browser, va_list ap);
|
||||
|
||||
|
||||
/* public */
|
||||
/* variables */
|
||||
DesktopWidgetDefinition widget =
|
||||
{
|
||||
"Browser",
|
||||
"file-manager",
|
||||
NULL,
|
||||
_browser_init,
|
||||
_browser_destroy,
|
||||
_browser_get_widget,
|
||||
_browser_set_property
|
||||
};
|
||||
|
||||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* browser_init */
|
||||
static BrowserWidget * _browser_init(char const * name)
|
||||
{
|
||||
BrowserWidget * browser;
|
||||
|
||||
if((browser = object_new(sizeof(*browser))) == NULL)
|
||||
return NULL;
|
||||
if((browser->browser = browser_new(NULL, NULL, NULL)) == NULL)
|
||||
{
|
||||
_browser_destroy(browser);
|
||||
return NULL;
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
|
||||
|
||||
/* browser_destroy */
|
||||
static void _browser_destroy(BrowserWidget * browser)
|
||||
{
|
||||
if(browser->browser != NULL)
|
||||
browser_delete(browser->browser);
|
||||
object_delete(browser);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* browser_get_widget */
|
||||
static GtkWidget * _browser_get_widget(BrowserWidget * browser)
|
||||
{
|
||||
return browser_get_widget(browser->browser);
|
||||
}
|
||||
|
||||
|
||||
/* browser_set_property */
|
||||
static int _browser_set_property(BrowserWidget * browser, va_list ap)
|
||||
{
|
||||
int ret = 0;
|
||||
String const * property;
|
||||
String const * s;
|
||||
unsigned int u;
|
||||
|
||||
while((property = va_arg(ap, String const *)) != NULL)
|
||||
if(strcmp(property, "location") == 0)
|
||||
{
|
||||
s = va_arg(ap, String const *);
|
||||
ret = browser_set_location(browser->browser, s);
|
||||
}
|
||||
else if(strcmp(property, "view") == 0)
|
||||
{
|
||||
u = va_arg(ap, unsigned int);
|
||||
browser_set_view(browser->browser, u);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include "../browser/callbacks.c"
|
@ -1,23 +1,14 @@
|
||||
targets=browser
|
||||
cppflags_force=-I../../include
|
||||
cflags_force=`pkg-config --cflags libDesktop` -fPIC
|
||||
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop` -lintl -L$(OBJDIR)../lib -Wl,-rpath,$(LIBDIR) -lBrowser
|
||||
ldflags=-Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile
|
||||
|
||||
#targets
|
||||
[browser]
|
||||
type=plugin
|
||||
sources=browser.c,callbacks.c,widget.c,window.c
|
||||
sources=browser.c
|
||||
install=$(LIBDIR)/Desktop/widget
|
||||
|
||||
#sources
|
||||
[browser.c]
|
||||
depends=../browser/browser.c,../browser/browser.h
|
||||
|
||||
[callbacks.c]
|
||||
depends=../browser/callbacks.c,../browser/callbacks.h
|
||||
|
||||
[window.c]
|
||||
depends=../browser/window.c,../browser/window.h
|
||||
[widget.c]
|
||||
depends=../browser/browser.c,../browser/callbacks.c,../browser/window.c,../browser/browser.h,../browser/callbacks.h,../browser/window.h
|
||||
|
@ -1,123 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#include "../browser/browser.h"
|
||||
#include "../browser/callbacks.h"
|
||||
|
||||
|
||||
/* BrowserWidget */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _DesktopWidgetPlugin
|
||||
{
|
||||
Browser * browser;
|
||||
} BrowserWidget;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static BrowserWidget * _browser_init(char const * name);
|
||||
static void _browser_destroy(BrowserWidget * browser);
|
||||
|
||||
static GtkWidget * _browser_get_widget(BrowserWidget * browser);
|
||||
|
||||
static int _browser_set_property(BrowserWidget * browser, va_list ap);
|
||||
|
||||
|
||||
/* public */
|
||||
/* variables */
|
||||
DesktopWidgetDefinition widget =
|
||||
{
|
||||
"Browser",
|
||||
"file-manager",
|
||||
NULL,
|
||||
_browser_init,
|
||||
_browser_destroy,
|
||||
_browser_get_widget,
|
||||
_browser_set_property
|
||||
};
|
||||
|
||||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* browser_init */
|
||||
static BrowserWidget * _browser_init(char const * name)
|
||||
{
|
||||
BrowserWidget * browser;
|
||||
(void) name;
|
||||
|
||||
if((browser = object_new(sizeof(*browser))) == NULL)
|
||||
return NULL;
|
||||
if((browser->browser = browser_new(NULL, NULL, NULL)) == NULL)
|
||||
{
|
||||
_browser_destroy(browser);
|
||||
return NULL;
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
|
||||
|
||||
/* browser_destroy */
|
||||
static void _browser_destroy(BrowserWidget * browser)
|
||||
{
|
||||
if(browser->browser != NULL)
|
||||
browser_delete(browser->browser);
|
||||
object_delete(browser);
|
||||
}
|
||||
|
||||
|
||||
/* accessors */
|
||||
/* browser_get_widget */
|
||||
static GtkWidget * _browser_get_widget(BrowserWidget * browser)
|
||||
{
|
||||
return browser_get_widget(browser->browser);
|
||||
}
|
||||
|
||||
|
||||
/* browser_set_property */
|
||||
static int _browser_set_property(BrowserWidget * browser, va_list ap)
|
||||
{
|
||||
int ret = 0;
|
||||
String const * property;
|
||||
String const * s;
|
||||
unsigned int u;
|
||||
|
||||
while((property = va_arg(ap, String const *)) != NULL)
|
||||
if(strcmp(property, "location") == 0)
|
||||
{
|
||||
s = va_arg(ap, String const *);
|
||||
ret = browser_set_location(browser->browser, s);
|
||||
}
|
||||
else if(strcmp(property, "view") == 0)
|
||||
{
|
||||
u = va_arg(ap, unsigned int);
|
||||
browser_set_view(browser->browser, u);
|
||||
}
|
||||
return ret;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
|
||||
|
||||
#include "../browser/window.c"
|
2
tests/.gitignore
vendored
2
tests/.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
/clint.log
|
||||
/fixme.log
|
||||
/htmllint.log
|
||||
/plugins
|
||||
/tests.log
|
||||
|
192
tests/clint.sh
192
tests/clint.sh
@ -1,192 +0,0 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2016-2021 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/clint.sh}/../config.sh"
|
||||
CFLAGS=
|
||||
CPPFLAGS=
|
||||
PROGNAME="clint.sh"
|
||||
PROJECTCONF="../project.conf"
|
||||
#executables
|
||||
DATE="date"
|
||||
DEBUG="_debug"
|
||||
ECHO="/bin/echo"
|
||||
FIND="find"
|
||||
GREP="grep"
|
||||
LINT="lint -g"
|
||||
MKDIR="mkdir -p"
|
||||
SORT="sort -n"
|
||||
TR="tr"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#clint
|
||||
_clint()
|
||||
{
|
||||
res=0
|
||||
subdirs=
|
||||
|
||||
$DATE
|
||||
while read line; do
|
||||
case "$line" in
|
||||
"["*)
|
||||
break
|
||||
;;
|
||||
"subdirs="*)
|
||||
subdirs=${line#subdirs=}
|
||||
subdirs=$(echo "$subdirs" | $TR ',' ' ')
|
||||
;;
|
||||
esac
|
||||
done < "$PROJECTCONF"
|
||||
if [ ! -n "$subdirs" ]; then
|
||||
_error "Could not locate directories to analyze"
|
||||
return $?
|
||||
fi
|
||||
for subdir in $subdirs; do
|
||||
[ -d "../$subdir" ] || continue
|
||||
while read filename; do
|
||||
[ -n "$filename" ] || continue
|
||||
r=0
|
||||
case "$filename" in
|
||||
*.c)
|
||||
echo
|
||||
_clint_lint "$filename" || r=$?
|
||||
_clint_rtrim "$filename"|| r=$?
|
||||
;;
|
||||
*.h)
|
||||
echo
|
||||
echo "$filename:"
|
||||
_clint_rtrim "$filename"|| r=$?
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
if [ $r -eq 0 ]; then
|
||||
echo " OK"
|
||||
echo "$PROGNAME: $filename: OK" 1>&2
|
||||
else
|
||||
echo "FAIL"
|
||||
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||
res=2
|
||||
fi
|
||||
done << EOF
|
||||
$($FIND "../$subdir" -type f | $SORT)
|
||||
EOF
|
||||
done
|
||||
return $res
|
||||
}
|
||||
|
||||
_clint_lint()
|
||||
{(
|
||||
filename="$1"
|
||||
|
||||
$ECHO -n "${filename%/*}/"
|
||||
$DEBUG $LINT $CPPFLAGS $CFLAGS "$filename" 2>&1
|
||||
ret=$?
|
||||
if [ $ret -eq 127 ]; then
|
||||
#XXX ignore errors when $LINT is not available
|
||||
ret=0
|
||||
fi
|
||||
return $ret
|
||||
)}
|
||||
|
||||
_clint_rtrim()
|
||||
{
|
||||
filename="$1"
|
||||
regex="[ ]\\+\$"
|
||||
|
||||
$DEBUG $GREP -vq "$regex" "$filename" 2>&1
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
echo "$@" 1>&3
|
||||
"$@"
|
||||
}
|
||||
|
||||
|
||||
#error
|
||||
_error()
|
||||
{
|
||||
echo "$PROGNAME: $@" 1>&2
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
clean=0
|
||||
while getopts "cO:P:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
P)
|
||||
CPPFLAGS="$CPPFLAGS -I$OPTARG/include"
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#clean
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
exec 3>&1
|
||||
ret=0
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
dirname="${target%/*}"
|
||||
shift
|
||||
|
||||
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||
$MKDIR -- "$dirname" || ret=$?
|
||||
fi
|
||||
_clint > "$target" || ret=$?
|
||||
done
|
||||
exit $ret
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2016-2024 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2016 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Desktop Browser
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -51,52 +51,5 @@ _embedded()
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
clean=0
|
||||
while getopts "cO:P:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
P)
|
||||
#XXX ignored for compatibility
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#clean
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
exec 3>&1
|
||||
ret=0
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
dirname="${target%/*}"
|
||||
shift
|
||||
|
||||
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||
$MKDIR -- "$dirname" || ret=$?
|
||||
fi
|
||||
_embedded > "$target" || ret=$?
|
||||
done
|
||||
exit $ret
|
||||
_embedded || exit 2
|
||||
|
261
tests/fixme.sh
261
tests/fixme.sh
@ -1,261 +0,0 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2017-2022 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/fixme.sh}/../config.sh"
|
||||
PROGNAME="fixme.sh"
|
||||
PROJECTCONF="../project.conf"
|
||||
REGEXP_ERROR="FIXME"
|
||||
REGEXP_WARNING="\\(TODO\|XXX\\)"
|
||||
#executables
|
||||
DATE="date"
|
||||
DEBUG="_debug"
|
||||
FIND="find"
|
||||
GREP="grep"
|
||||
HEAD="head"
|
||||
MKDIR="mkdir -p"
|
||||
SORT="sort -n"
|
||||
TR="tr"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#fixme
|
||||
_fixme()
|
||||
{
|
||||
res=0
|
||||
subdirs=
|
||||
|
||||
$DATE
|
||||
echo
|
||||
while read line; do
|
||||
case "$line" in
|
||||
"["*)
|
||||
break
|
||||
;;
|
||||
"subdirs="*)
|
||||
subdirs=${line#subdirs=}
|
||||
subdirs=$(echo "$subdirs" | $TR ',' ' ')
|
||||
;;
|
||||
esac
|
||||
done < "$PROJECTCONF"
|
||||
if [ ! -n "$subdirs" ]; then
|
||||
_error "Could not locate directories to analyze"
|
||||
return $?
|
||||
fi
|
||||
for subdir in $subdirs; do
|
||||
[ -d "../$subdir" ] || continue
|
||||
for filename in $($FIND "../$subdir" -type f | $SORT); do
|
||||
callback=$(_fixme_callback "$filename")
|
||||
[ -n "$callback" ] || continue
|
||||
($callback "$filename") 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||
res=2
|
||||
fi
|
||||
done
|
||||
done
|
||||
return $res
|
||||
}
|
||||
|
||||
_fixme_callback()
|
||||
{
|
||||
filename="$1"
|
||||
ext=${filename##*/}
|
||||
ext=${ext%.in}
|
||||
ext=${ext##*.}
|
||||
callback=
|
||||
|
||||
case "$ext" in
|
||||
asm|S)
|
||||
echo "_fixme_callback_asm"
|
||||
return 0
|
||||
;;
|
||||
c|cc|cpp|cxx|go|h|js|v)
|
||||
echo "_fixme_callback_c"
|
||||
return 0
|
||||
;;
|
||||
conf|sh)
|
||||
echo "_fixme_callback_sh"
|
||||
return 0
|
||||
;;
|
||||
py)
|
||||
echo "_fixme_callback_python"
|
||||
return 0
|
||||
;;
|
||||
htm|html|xml|xsl)
|
||||
echo "_fixme_callback_xml"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
case $($HEAD -n 1 "$filename") in
|
||||
"#!/bin/sh"*|"#! /bin/sh"*|\
|
||||
"#!/usr/bin/env bash"*|"#! /usr/bin/env bash"*)
|
||||
echo "_fixme_callback_sh"
|
||||
return 0
|
||||
;;
|
||||
"#!/usr/bin/env python"*|"#! /usr/bin/env python"*)
|
||||
echo "_fixme_callback_python"
|
||||
return 0
|
||||
;;
|
||||
"<!DOCTYPE"*|"<!doctype"*|"<HTML"*|"<html"*|"<?xml"*)
|
||||
echo "_fixme_callback_xml"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 2
|
||||
}
|
||||
|
||||
_fixme_callback_asm()
|
||||
{
|
||||
res=0
|
||||
filename="$1"
|
||||
|
||||
#warnings
|
||||
$GREP -nH "/\\*.*$REGEXP_WARNING" "$filename"
|
||||
#failures
|
||||
$GREP -nH "/\\*.*$REGEXP_ERROR" "$filename" && res=2
|
||||
return $res
|
||||
}
|
||||
|
||||
_fixme_callback_c()
|
||||
{
|
||||
res=0
|
||||
filename="$1"
|
||||
|
||||
#warnings
|
||||
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_WARNING" "$filename"
|
||||
#failures
|
||||
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_ERROR" "$filename" && res=2
|
||||
return $res
|
||||
}
|
||||
|
||||
_fixme_callback_python()
|
||||
{
|
||||
res=0
|
||||
filename="$1"
|
||||
comment="#"
|
||||
|
||||
#warnings
|
||||
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
|
||||
#failures
|
||||
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
|
||||
return $res
|
||||
}
|
||||
|
||||
_fixme_callback_sh()
|
||||
{
|
||||
res=0
|
||||
filename="$1"
|
||||
comment="#"
|
||||
|
||||
#warnings
|
||||
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
|
||||
#failures
|
||||
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
|
||||
return $res
|
||||
}
|
||||
|
||||
_fixme_callback_xml()
|
||||
{
|
||||
res=0
|
||||
filename="$1"
|
||||
|
||||
#XXX limited to a single line
|
||||
#warnings
|
||||
$GREP -nH "<!--.*$REGEXP_WARNING" "$filename"
|
||||
#failures
|
||||
$GREP -nH "<!--.*$REGEXP_ERROR" "$filename" && res=2
|
||||
return $res
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
echo "$@" 1>&3
|
||||
"$@"
|
||||
}
|
||||
|
||||
|
||||
#error
|
||||
_error()
|
||||
{
|
||||
echo "$PROGNAME: $@" 1>&2
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: $PROGNAME [-c] target..." 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
clean=0
|
||||
while getopts "cO:P:" name; do
|
||||
case "$name" in
|
||||
c)
|
||||
clean=1
|
||||
;;
|
||||
O)
|
||||
export "${OPTARG%%=*}"="${OPTARG#*=}"
|
||||
;;
|
||||
P)
|
||||
#XXX ignored for compatibility
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
if [ $# -lt 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
#clean
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
exec 3>&1
|
||||
ret=0
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
dirname="${target%/*}"
|
||||
shift
|
||||
|
||||
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||
$MKDIR -- "$dirname" || ret=$?
|
||||
fi
|
||||
_fixme > "$target" || ret=$?
|
||||
done
|
||||
exit $ret
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2014-2021 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2014-2017 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -25,31 +25,26 @@
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/htmllint.sh}/../config.sh"
|
||||
DEVNULL="/dev/null"
|
||||
PROGNAME="htmllint.sh"
|
||||
PROJECTCONF="../project.conf"
|
||||
#executables
|
||||
DATE="date"
|
||||
DEBUG="_debug"
|
||||
ECHO="/bin/echo"
|
||||
FIND="find"
|
||||
HTMLLINT="xmllint --html --nonet"
|
||||
MKDIR="mkdir -p"
|
||||
HTMLLINT="xmllint --html"
|
||||
SORT="sort -n"
|
||||
TR="tr"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
|
||||
|
||||
#functions
|
||||
#htmllint
|
||||
_htmllint()
|
||||
{
|
||||
res=0
|
||||
subdirs=
|
||||
ret=0
|
||||
|
||||
$DATE
|
||||
echo
|
||||
while read line; do
|
||||
case "$line" in
|
||||
"["*)
|
||||
@ -61,30 +56,19 @@ _htmllint()
|
||||
;;
|
||||
esac
|
||||
done < "$PROJECTCONF"
|
||||
if [ ! -n "$subdirs" ]; then
|
||||
_error "Could not locate directories to analyze"
|
||||
return $?
|
||||
fi
|
||||
for subdir in $subdirs; do
|
||||
[ -d "../$subdir" ] || continue
|
||||
while read filename; do
|
||||
[ -n "$filename" ] || continue
|
||||
echo
|
||||
$ECHO -n "$filename:"
|
||||
for filename in $($FIND "../$subdir" -iname '*.html' -o -iname '*.htm' | $SORT); do
|
||||
$DEBUG $HTMLLINT "$filename" 2>&1 > "$DEVNULL"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " OK"
|
||||
echo "$PROGNAME: $filename: OK" 1>&2
|
||||
echo "$filename:"
|
||||
else
|
||||
echo "FAIL"
|
||||
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||
res=2
|
||||
ret=2
|
||||
fi
|
||||
done << EOF
|
||||
$($FIND "../$subdir" -type f -a \( -iname '*.html' -o -iname '*.htm' \) | $SORT)
|
||||
EOF
|
||||
done
|
||||
done
|
||||
return $res
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
||||
@ -93,14 +77,10 @@ _debug()
|
||||
{
|
||||
echo "$@" 1>&3
|
||||
"$@"
|
||||
}
|
||||
|
||||
|
||||
#error
|
||||
_error()
|
||||
{
|
||||
echo "$PROGNAME: $@" 1>&2
|
||||
return 2
|
||||
res=$?
|
||||
#ignore errors when the command is not available
|
||||
[ $res -eq 127 ] && return 0
|
||||
return $res
|
||||
}
|
||||
|
||||
|
||||
@ -141,15 +121,9 @@ fi
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
exec 3>&1
|
||||
ret=0
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
dirname="${target%/*}"
|
||||
shift
|
||||
|
||||
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||
$MKDIR -- "$dirname" || ret=$?
|
||||
fi
|
||||
_htmllint > "$target" || ret=$?
|
||||
_htmllint > "$target" || exit 2
|
||||
done
|
||||
exit $ret
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2013-2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2013-2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -54,8 +58,6 @@ static int _plugins(void)
|
||||
const char path[] = "../src/plugins"; /* FIXME broken with OBJDIR */
|
||||
#ifdef __APPLE__
|
||||
const char ext[] = ".dylib";
|
||||
#elif defined(__WIN32__)
|
||||
const char ext[] = ".dll";
|
||||
#else
|
||||
const char ext[] = ".so";
|
||||
#endif
|
||||
|
@ -1,46 +1,14 @@
|
||||
targets=clint.log,embedded.log,fixme.log,htmllint.log,plugins,tests.log,vfs,xmllint.log
|
||||
targets=htmllint.log,plugins,vfs,tests.log,xmllint.log
|
||||
cppflags_force=-I ../include
|
||||
cflags_force=`pkg-config --cflags libDesktop`
|
||||
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
ldflags_force=`pkg-config --libs libDesktop`
|
||||
ldflags=-pie -Wl,-z,relro -Wl,-z,now
|
||||
dist=Makefile,clint.sh,embedded.sh,fixme.sh,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh
|
||||
|
||||
#modes
|
||||
[mode::embedded-debug]
|
||||
cppflags_force=-DEMBEDDED
|
||||
|
||||
[mode::embedded-release]
|
||||
cppflags_force=-DEMBEDDED -DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
[mode::release]
|
||||
cppflags_force=-DNDEBUG
|
||||
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||
|
||||
#targets
|
||||
[clint.log]
|
||||
type=script
|
||||
script=./clint.sh
|
||||
enabled=0
|
||||
depends=clint.sh
|
||||
|
||||
[embedded.log]
|
||||
type=script
|
||||
script=./embedded.sh
|
||||
enabled=0
|
||||
depends=embedded.sh
|
||||
|
||||
[fixme.log]
|
||||
type=script
|
||||
script=./fixme.sh
|
||||
enabled=0
|
||||
depends=fixme.sh
|
||||
dist=Makefile,embedded.sh,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh
|
||||
|
||||
[htmllint.log]
|
||||
type=script
|
||||
script=./htmllint.sh
|
||||
enabled=0
|
||||
depends=htmllint.sh
|
||||
|
||||
[plugins]
|
||||
@ -51,7 +19,6 @@ ldflags=-ldl
|
||||
[tests.log]
|
||||
type=script
|
||||
script=./tests.sh
|
||||
enabled=0
|
||||
depends=pkgconfig.sh,$(OBJDIR)plugins$(EXEEXT),$(OBJDIR)vfs$(EXEEXT),tests.sh
|
||||
|
||||
[vfs]
|
||||
@ -62,5 +29,4 @@ sources=vfs.c
|
||||
[xmllint.log]
|
||||
type=script
|
||||
script=./xmllint.sh
|
||||
enabled=0
|
||||
depends=xmllint.sh
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2013-2024 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2013-2016 Pierre Pronchery <khorben@defora.org>
|
||||
#This file is part of DeforaOS Desktop Browser
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are
|
||||
@ -13,6 +13,10 @@
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
#3. Neither the name of the authors nor the names of the contributors may be
|
||||
# used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -29,11 +33,8 @@
|
||||
#variables
|
||||
[ -n "$OBJDIR" ] || OBJDIR="./"
|
||||
PROGNAME="tests.sh"
|
||||
SYSTEM="$(uname -s)"
|
||||
#executables
|
||||
DATE="date"
|
||||
ECHO="echo"
|
||||
[ "$SYSTEM" = "Darwin" ] && ECHO="/bin/echo"
|
||||
|
||||
|
||||
#functions
|
||||
@ -50,7 +51,7 @@ _run()
|
||||
test="$1"
|
||||
|
||||
shift
|
||||
$ECHO -n "$test:" 1>&2
|
||||
echo -n "$test:" 1>&2
|
||||
(echo
|
||||
echo "Testing: $test" "$@"
|
||||
testexe="./$test"
|
||||
|
10
tests/vfs.c
10
tests/vfs.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2015-2022 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2015 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Browser */
|
||||
/* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
@ -12,6 +12,10 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the authors nor the names of the contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
@ -75,9 +79,7 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
int o;
|
||||
|
||||
/* XXX avoid failures when offscreen */
|
||||
if(getenv("DISPLAY") != NULL)
|
||||
gtk_init(&argc, &argv);
|
||||
gtk_init(&argc, &argv);
|
||||
while((o = getopt(argc, argv, "")) != -1)
|
||||
switch(o)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2014-2021 Pierre Pronchery <khorben@defora.org>
|
||||
#Copyright (c) 2014-2017 Pierre Pronchery <khorben@defora.org>
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions are met:
|
||||
@ -25,31 +25,26 @@
|
||||
|
||||
|
||||
#variables
|
||||
CONFIGSH="${0%/xmllint.sh}/../config.sh"
|
||||
DEVNULL="/dev/null"
|
||||
PROGNAME="xmllint.sh"
|
||||
PROJECTCONF="../project.conf"
|
||||
#executables
|
||||
DATE="date"
|
||||
DEBUG="_debug"
|
||||
ECHO="/bin/echo"
|
||||
FIND="find"
|
||||
MKDIR="mkdir -p"
|
||||
SORT="sort -n"
|
||||
TR="tr"
|
||||
XMLLINT="xmllint --nonet --xinclude"
|
||||
|
||||
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
|
||||
XMLLINT="xmllint"
|
||||
|
||||
|
||||
#functions
|
||||
#xmllint
|
||||
_xmllint()
|
||||
{
|
||||
res=0
|
||||
subdirs=
|
||||
ret=0
|
||||
|
||||
$DATE
|
||||
echo
|
||||
while read line; do
|
||||
case "$line" in
|
||||
"["*)
|
||||
@ -61,30 +56,19 @@ _xmllint()
|
||||
;;
|
||||
esac
|
||||
done < "$PROJECTCONF"
|
||||
if [ ! -n "$subdirs" ]; then
|
||||
_error "Could not locate directories to analyze"
|
||||
return $?
|
||||
fi
|
||||
for subdir in $subdirs; do
|
||||
[ -d "../$subdir" ] || continue
|
||||
while read filename; do
|
||||
[ -n "$filename" ] || continue
|
||||
echo
|
||||
$ECHO -n "$filename:"
|
||||
for filename in $($FIND "../$subdir" -name '*.xml' -o -name '*.xsl' | $SORT); do
|
||||
$DEBUG $XMLLINT "$filename" 2>&1 > "$DEVNULL"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " OK"
|
||||
echo "$PROGNAME: $filename: OK" 1>&2
|
||||
echo "$filename:"
|
||||
else
|
||||
echo "FAIL"
|
||||
echo "$PROGNAME: $filename: FAIL" 1>&2
|
||||
res=2
|
||||
ret=2
|
||||
fi
|
||||
done << EOF
|
||||
$($FIND "../$subdir" -type f -a \( -iname '*.xml' -o -iname '*.xsl' \) | $SORT)
|
||||
EOF
|
||||
done
|
||||
done
|
||||
return $res
|
||||
return $ret
|
||||
}
|
||||
|
||||
|
||||
@ -93,14 +77,10 @@ _debug()
|
||||
{
|
||||
echo "$@" 1>&3
|
||||
"$@"
|
||||
}
|
||||
|
||||
|
||||
#error
|
||||
_error()
|
||||
{
|
||||
echo "$PROGNAME: $@" 1>&2
|
||||
return 2
|
||||
res=$?
|
||||
#ignore errors when the command is not available
|
||||
[ $res -eq 127 ] && return 0
|
||||
return $res
|
||||
}
|
||||
|
||||
|
||||
@ -141,15 +121,9 @@ fi
|
||||
[ $clean -ne 0 ] && exit 0
|
||||
|
||||
exec 3>&1
|
||||
ret=0
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
dirname="${target%/*}"
|
||||
shift
|
||||
|
||||
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
|
||||
$MKDIR -- "$dirname" || ret=$?
|
||||
fi
|
||||
_xmllint > "$target" || ret=$?
|
||||
_xmllint > "$target" || exit 2
|
||||
done
|
||||
exit $ret
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user