Added a tool to start the file browser in the snapshot directory

This commit is contained in:
Pierre Pronchery 2013-01-18 22:16:34 +01:00
parent e2f60dd4fe
commit ad00e710da
5 changed files with 136 additions and 2 deletions

View File

@ -1,6 +1,6 @@
PACKAGE = Camera
VERSION = 0.0.0
SUBDIRS = data src
SUBDIRS = data src tools
RM = rm -f
LN = ln -f
TAR = tar -czvf
@ -29,6 +29,9 @@ dist:
$(PACKAGE)-$(VERSION)/src/Makefile \
$(PACKAGE)-$(VERSION)/src/camera.h \
$(PACKAGE)-$(VERSION)/src/project.conf \
$(PACKAGE)-$(VERSION)/tools/gallery.c \
$(PACKAGE)-$(VERSION)/tools/Makefile \
$(PACKAGE)-$(VERSION)/tools/project.conf \
$(PACKAGE)-$(VERSION)/Makefile \
$(PACKAGE)-$(VERSION)/config.h \
$(PACKAGE)-$(VERSION)/project.conf

View File

@ -1,6 +1,6 @@
package=Camera
version=0.0.0
subdirs=data,src
subdirs=data,src,tools
config=h
dist=Makefile,config.h

40
tools/Makefile Normal file
View File

@ -0,0 +1,40 @@
TARGETS = gallery
PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
SBINDIR = $(PREFIX)/sbin
CC = cc
CPPFLAGSF=
CPPFLAGS=
CFLAGSF = -W `pkg-config --cflags glib-2.0`
CFLAGS = -Wall -g -O2
LDFLAGS = `pkg-config --libs glib-2.0`
RM = rm -f
LN = ln -f
MKDIR = mkdir -p
INSTALL = install
all: $(TARGETS)
gallery_OBJS = gallery.o
gallery_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
gallery_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
gallery: $(gallery_OBJS)
$(CC) -o gallery $(gallery_OBJS) $(gallery_LDFLAGS)
gallery.o: gallery.c
$(CC) $(gallery_CFLAGS) -c gallery.c
clean:
$(RM) -- $(gallery_OBJS)
distclean: clean
$(RM) -- $(TARGETS)
install: $(TARGETS)
uninstall:
.PHONY: all clean distclean install uninstall

82
tools/gallery.c Normal file
View File

@ -0,0 +1,82 @@
/* $Id$ */
/* Copyright (c) 2013 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS desktop camera */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
/* Gallery */
/* private */
/* prototypes */
static int _gallery(void);
/* functions */
/* gallery */
static int _gallery(void)
{
char const gallery[] = "gallery";
char const * homedir;
char const dcim[] = "DCIM";
char * path;
char * argv[] = { "browser", "--", NULL, NULL };
if((homedir = getenv("HOME")) == NULL)
homedir = g_get_home_dir();
if((path = g_build_filename(homedir, dcim, NULL)) == NULL)
{
/* XXX errno may not be set */
fprintf(stderr, "%s: %s\n", gallery, strerror(errno));
return -1;
}
argv[2] = path;
execvp(argv[0], argv);
fprintf(stderr, "%s: %s: %s\n", gallery, argv[0], strerror(errno));
g_free(path);
return -1;
}
/* usage */
static int _usage(void)
{
fputs("Usage: gallery\n", stderr);
return 1;
}
/* public */
/* functions */
/* main */
int main(int argc, char * argv[])
{
int o;
while((o = getopt(argc, argv, "")) != -1)
switch(o)
{
default:
return _usage();
}
if(optind != argc)
return _usage();
return (_gallery() == 0) ? 0 : 2;
}

9
tools/project.conf Normal file
View File

@ -0,0 +1,9 @@
targets=gallery
cflags_force=-W `pkg-config --cflags glib-2.0`
cflags=-Wall -g -O2
ldflags=`pkg-config --libs glib-2.0`
dist=Makefile
[gallery]
type=binary
sources=gallery.c