Commit 31aeb6bf authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Initial commit

cmake_minimum_required(VERSION 2.6)
# Copyright ETIS — ENSEA, Université de Cergy-Pontoise, CNRS (2011 - 2016)
# Author: Arnaud Blanchard (November 2016)
# This software is governed by the CeCILL v2.1 license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL v2.1 license as circulated by CEA, CNRS and INRIA at the following URL "".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
# users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge.
# Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured  and, more generally, to use and operate it in the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms.
cd `dirname $0`
echo "Checking `basename $PWD`"
echo "===================="
echo "No check for now"
# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 2.6)
#This is to be able to debug and recompile automatically the libs (shared_blc). It is slower, you can remove this line and use : ${BLAR_BUILD_DIR}/lib/libblc.dylib instead of shared_blc
find_package(blc_channel REQUIRED)
find_package(blc_image REQUIRED)
find_package(blc_program REQUIRED)
find_package(blgtk REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
find_package(JPEG REQUIRED)
add_definitions(-Wall ${BL_DEFINITIONS} -Wno-deprecated-declarations) #device_manager (mouse) is deprecated
add_executable(o_gtk_image src/o_gtk_image.cpp src/image_display.cpp)
target_link_libraries(o_gtk_image ${GTK3_LIBRARIES} ${BL_LIBRARIES} ${JPEG_LIBRARIES} )
This diff is collapsed.
#include <gtk/gtk.h>
#include <blc_channel.h>
GtkWidget *create_image_display(blc_channel *channel);
\ No newline at end of file
#include "o_gtk_image.hpp"
#include <fcntl.h> // O_RDONLY ...
#include <stdio.h>
#include <gtk/gtk.h>
#include <string.h>
#include <stdint.h> //uint32_t
//#include <jpeglib.h>
#include <sys/mman.h>
#include <errno.h> //errno
#include "blc_core.h"
#include "blc_program.h"
#include "image_display.hpp"
const char *channel_name, *fullscreen_option, *keyboard_mode;
GtkWidget *window;
GdkDisplay *main_display;
GdkDevice *pointer_device;
int interactive_mode=0;
GtkApplication *app;
blc_channel mouse_channel;
blc_channel input;
char const *input_name;
int input_terminal;
int mode;
char const *format_string;
uint32_t format;
void ask_fullscreen(){
void ask_quit()
void on_key_press(GtkWidget *widget, GdkEventKey *event){
char key;
if (event->type == GDK_KEY_PRESS){
fwrite(&key, 1, 1, stdout);
void activate_cb(GApplication *app)
blc_channel *input;
char tmp_title[NAME_MAX*2+1];
GtkWidget *display=NULL;
GtkWidget *grid;
main_display = gdk_display_get_default ();
GdkDeviceManager *device_manager = gdk_display_get_device_manager (main_display);
pointer_device = gdk_device_manager_get_client_pointer (device_manager);
SPRINTF(tmp_title, "%s", blc_program_name);
gtk_window_set_title(GTK_WINDOW(window), tmp_title);
// for(i=0; input_names[i]; i++){ This is for displaying multiple images
input=new blc_channel(/*input_names[i]*/ input_name, BLC_CHANNEL_READ);
if (display==NULL) EXIT_ON_CHANNEL_ERROR(input, "Format not managed.");
gtk_widget_set_hexpand(display, 1);
gtk_widget_set_vexpand(display, 1);
gtk_container_add(GTK_CONTAINER(grid), display);
// }
gtk_container_add(GTK_CONTAINER(window), grid);
if (keyboard_mode) g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK (on_key_press), NULL);
/** Classical GTK application.
* The first optional argument is the name of the experience. Otherwise all the existing shared memory are used.
* */
int main(int argc, char *argv[])
int status=0;
char const *g_debug, *mouse_name;
blc_channel channel_info;
blc_program_set_description("Display the content of the blc_channel depending on its type on format");
blc_program_add_option(&keyboard_mode, 'k', "keyboard", NULL, "Send keyboard input to stdout", NULL);
blc_program_add_option(&mouse_name, 'm', "mouse", "blc_channel-out", "return the mouse coordinates and status in the channel", NULL);
blc_program_add_option(&fullscreen_option, 'F', "fullscreen", NULL, "Set the window in fullscreen", NULL);
blc_program_add_option(&g_debug, ' ', "g-fatal-warnings", NULL, "Debug gtk.", NULL);
// This function is not yer operaiotnal blc_program_add_multiple_parameters(&input_names, "blc_channel", 1, "channel name you want to display");
blc_program_add_parameter(&input_name, "blc_channel-in", 1, "channel name you want to display", NULL);
blc_program_init(&argc, &argv, ask_quit);, mode);
gtk_init(&argc, &argv);
app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
status = g_application_run(G_APPLICATION(app), 0, NULL);
return (status);
#ifndef MAIN_HPP
#define MAIN_HPP
#include <gtk/gtk.h>
#include <blc_channel.h>
extern GtkWidget *window;
extern GdkDisplay *main_display;
extern GdkDevice *pointer_device;
extern GtkApplication *app;
extern blc_channel mouse_channel;
extern int interactive_mode;
extern uint32_t format;
extern char const *fullscreen_option;
void quit();
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment