Introduce a dummy backend
This commit is contained in:
parent
2e109ea4c4
commit
a9bc1b8e38
34
src/backend.c
Normal file
34
src/backend.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Flashlight */
|
||||||
|
/* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 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. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend.h"
|
||||||
|
|
||||||
|
#warning Unsupported platform: using dummy backend
|
||||||
|
#include "backend/dummy.c"
|
50
src/backend.h
Normal file
50
src/backend.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Flashlight */
|
||||||
|
/* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 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. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLASHLIGHT_BACKEND_H
|
||||||
|
# define FLASHLIGHT_BACKEND_H
|
||||||
|
|
||||||
|
|
||||||
|
/* FlashlightBackend */
|
||||||
|
/* types */
|
||||||
|
typedef enum _FlashlightBackendActive
|
||||||
|
{
|
||||||
|
FBA_UNKNOWN = -1,
|
||||||
|
FBA_INACTIVE = 0,
|
||||||
|
FBA_ACTIVE = 1
|
||||||
|
} FlashlightBackendActive;
|
||||||
|
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
/* accessors */
|
||||||
|
FlashlightBackendActive flashlightbackend_get(void);
|
||||||
|
int flashlightbackend_set(FlashlightBackendActive active);
|
||||||
|
|
||||||
|
#endif /* !FLASHLIGHT_BACKEND_H */
|
45
src/backend/dummy.c
Normal file
45
src/backend/dummy.c
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Flashlight */
|
||||||
|
/* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 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. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "../backend.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* flashlightbackend_get */
|
||||||
|
FlashlightBackendActive flashlightbackend_get(void)
|
||||||
|
{
|
||||||
|
return FBA_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* flashlightbackend_set */
|
||||||
|
int flashlightbackend_set(FlashlightBackendActive active)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
1
src/backend/project.conf
Normal file
1
src/backend/project.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dist=Makefile,dummy.c
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <System.h>
|
#include <System.h>
|
||||||
#include <Desktop.h>
|
#include <Desktop.h>
|
||||||
|
#include "backend.h"
|
||||||
#include "flashlight.h"
|
#include "flashlight.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,8 +95,16 @@ void flashlight_delete(Flashlight * flashlight)
|
||||||
/* flashlight_get_active */
|
/* flashlight_get_active */
|
||||||
gboolean flashlight_get_active(Flashlight * flashlight)
|
gboolean flashlight_get_active(Flashlight * flashlight)
|
||||||
{
|
{
|
||||||
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
switch(flashlightbackend_get())
|
||||||
flashlight->co_main));
|
{
|
||||||
|
case FBA_ACTIVE:
|
||||||
|
return TRUE;
|
||||||
|
case FBA_INACTIVE:
|
||||||
|
return FALSE;
|
||||||
|
default:
|
||||||
|
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
|
flashlight->co_main));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +118,7 @@ GtkWidget * flashlight_get_widget(Flashlight * flashlight)
|
||||||
/* flashlight_set_active */
|
/* flashlight_set_active */
|
||||||
void flashlight_set_active(Flashlight * flashlight, gboolean active)
|
void flashlight_set_active(Flashlight * flashlight, gboolean active)
|
||||||
{
|
{
|
||||||
|
flashlightbackend_set(active);
|
||||||
gtk_widget_set_sensitive(flashlight->image, active);
|
gtk_widget_set_sensitive(flashlight->image, active);
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flashlight->co_main),
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flashlight->co_main),
|
||||||
active);
|
active);
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
|
subdirs=backend
|
||||||
targets=flashlight
|
targets=flashlight
|
||||||
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all
|
cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all
|
||||||
ldflags=-Wl,-pie -Wl,-z,relro -Wl,-z,now
|
ldflags=-Wl,-pie -Wl,-z,relro -Wl,-z,now
|
||||||
cflags_force=`pkg-config --cflags libDesktop`
|
cflags_force=`pkg-config --cflags libDesktop`
|
||||||
ldflags_force=`pkg-config --libs libDesktop`
|
ldflags_force=`pkg-config --libs libDesktop`
|
||||||
dist=Makefile,flashlight.h,window.h
|
dist=Makefile,backend.h,flashlight.h,window.h
|
||||||
|
|
||||||
[flashlight]
|
[flashlight]
|
||||||
type=binary
|
type=binary
|
||||||
sources=flashlight.c,window.c,main.c
|
sources=backend.c,flashlight.c,window.c,main.c
|
||||||
|
|
||||||
|
[backend.c]
|
||||||
|
depends=backend.h,backend/dummy.c
|
||||||
|
|
||||||
[flashlight.c]
|
[flashlight.c]
|
||||||
depends=flashlight.h
|
depends=backend.h,flashlight.h
|
||||||
|
|
||||||
[main.c]
|
[main.c]
|
||||||
depends=window.h,../config.h
|
depends=window.h,../config.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user