Commit 63dfc873 authored by Sergio Costas's avatar Sergio Costas

Added wayland support (now it doesn't crash)

Added DBus remote control
parent f86f57bd
......@@ -9,6 +9,10 @@ enable_testing ()
option(ICON_UPDATE "Update the icon cache after installing" ON)
option(BUILD_VALADOC "Build API documentation if Valadoc is available" OFF)
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE Release)
endif()
include(GNUInstallDirs)
if( ( ${CMAKE_INSTALL_PREFIX} MATCHES "^/usr/local" ) )
# A workaround to ensure that works 'out of the box' in Debian-based systems
......@@ -45,6 +49,7 @@ set(MODULES_TO_CHECK ${MODULES_TO_CHECK} x11)
pkg_check_modules(DEPS REQUIRED ${MODULES_TO_CHECK})
find_program ( WHERE_GRESOURCE glib-compile-resources )
if ( NOT WHERE_GRESOURCE )
MESSAGE(FATAL_ERROR "Error! GLIB-COMPILE-RESOURCES is not installed.")
......
## History of versions ##
* Version 0.5.0 (2016-12-12)
* Added Wayland support
* Added DBus remote control
* Version 0.4.0 (2016-09-17)
* Fixed the window size during startup
* Fixed resize bug when moving the mouse too fast
* Fixed the "Copy" function. Now it copies the text to the clipboard
* Fixed the window size during startup
* Fixed resize bug when moving the mouse too fast
* Fixed the "Copy" function. Now it copies the text to the clipboard
* Version 0.3.0 (2016-08-24)
* Fixed compilation paths
* Now can be compiled with valac-0.30
* Added package files
* Fixed compilation paths
* Now can be compiled with valac-0.30
* Added package files
* Version 0.2.0 (2016-08-24)
* Fixed resizing
* Cyclic jump from tab to tab using Page Down and Page Up
* Added note in the README to fix the focus problem in Gnome Shell
* Fixed resizing
* Cyclic jump from tab to tab using Page Down and Page Up
* Added note in the README to fix the focus problem in Gnome Shell
* Version 0.1.0 (2016-08-23)
* First public version
* First public version
##
# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
# Copyright 2012 elementary.
#
#
# 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 JAKOB WESTHOFF ``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
......@@ -22,7 +22,7 @@
# 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.
#
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of Jakob Westhoff
......@@ -32,30 +32,30 @@ include(ParseArguments)
find_package(Vala REQUIRED)
##
# Compile vala files to their c equivalents for further processing.
# Compile vala files to their c equivalents for further processing.
#
# The "vala_precompile" macro takes care of calling the valac executable on the
# given source to produce c files which can then be processed further using
# default cmake functions.
#
#
# The first parameter provided is a variable, which will be filled with a list
# of c files outputted by the vala compiler. This list can than be used in
# conjuction with functions like "add_executable" or others to create the
# neccessary compile rules with CMake.
#
#
# The initial variable is followed by a list of .vala files to be compiled.
# Please take care to add every vala file belonging to the currently compiled
# project or library as Vala will otherwise not be able to resolve all
# dependencies.
#
#
# The following sections may be specified afterwards to provide certain options
# to the vala compiler:
#
#
# PACKAGES
# A list of vala packages/libraries to be used during the compile cycle. The
# package names are exactly the same, as they would be passed to the valac
# "--pkg=" option.
#
#
# OPTIONS
# A list of optional options to be passed to the valac executable. This can be
# used to pass "--thread" for example to enable multi-threading support.
......@@ -69,7 +69,7 @@ find_package(Vala REQUIRED)
# Pass all the needed flags to the compiler to create an internal vapi for
# the compiled library. The provided name will be used for this and a
# <provided_name>.vapi file will be created.
#
#
# GENERATE_HEADER
# Let the compiler generate a header file for the compiled code. There will
# be a header file as well as an internal header file being generated called
......@@ -82,7 +82,7 @@ find_package(Vala REQUIRED)
#
# GENERATE_SYMBOLS
# Output a <provided_name>.symbols file containing all the exported symbols.
#
#
# The following call is a simple example to the vala_precompile macro showing
# an example to every of the optional sections:
#
......@@ -197,7 +197,7 @@ macro(vala_precompile output target_name)
list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols")
set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols")
endif(ARGS_GENERATE_SYMBOLS)
set(os_defines "")
if(WIN32)
list(APPEND os_defines "-D" "\"G_OS_WIN32\"")
......@@ -211,27 +211,27 @@ macro(vala_precompile output target_name)
add_custom_command(
OUTPUT
${OUTPUT_STAMP}
COMMAND
${VALA_EXECUTABLE}
ARGS
"-C"
${header_arguments}
${vapi_arguments}
${gir_arguments}
${symbols_arguments}
"-b" ${CMAKE_CURRENT_SOURCE_DIR}
"-d" ${DIRECTORY}
${os_defines}
${vala_pkg_opts}
${ARGS_OPTIONS}
${in_files}
COMMAND
${VALA_EXECUTABLE}
ARGS
"-C"
${header_arguments}
${vapi_arguments}
${gir_arguments}
${symbols_arguments}
"-b" ${CMAKE_CURRENT_SOURCE_DIR}
"-d" ${DIRECTORY}
${os_defines}
${vala_pkg_opts}
${ARGS_OPTIONS}
${in_files}
${custom_vapi_arguments}
COMMAND
touch
ARGS
${OUTPUT_STAMP}
DEPENDS
${in_files}
DEPENDS
${in_files}
${ARGS_CUSTOM_VAPIS}
COMMENT
"Generating ${out_files_display}"
......
### CMakeLists automatically created with AutoVala
### Do not edit
SET(DBUS_PREFIX ${CMAKE_INSTALL_PREFIX})
EXECUTE_PROCESS( COMMAND glib-compile-resources --sourcedir=${CMAKE_CURRENT_SOURCE_DIR} --generate-source --target=${CMAKE_CURRENT_BINARY_DIR}/extras.gresource.xml.c ${CMAKE_CURRENT_SOURCE_DIR}/extras.gresource.xml)
EXECUTE_PROCESS( COMMAND glib-compile-resources --sourcedir=${CMAKE_CURRENT_SOURCE_DIR} --generate-header --target=${CMAKE_CURRENT_BINARY_DIR}/extras.gresource.xml.h ${CMAKE_CURRENT_SOURCE_DIR}/extras.gresource.xml)
ADD_CUSTOM_COMMAND (
......@@ -14,6 +15,7 @@ ADD_CUSTOM_COMMAND (
add_custom_target(extras_gresource_xml DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/extras.gresource.xml.c)
SET (extras_gresource_xml_C_FILE ${CMAKE_CURRENT_BINARY_DIR}/extras.gresource.xml.c PARENT_SCOPE)
SET (extras_gresource_xml_H_FILE ${CMAKE_CURRENT_BINARY_DIR}/extras.gresource.xml.h PARENT_SCOPE)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/terminus_showhide.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/terminus.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications/ )
if( NOT ( ${CMAKE_INSTALL_PREFIX} MATCHES "^/home/" ) )
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/terminus_autorun.desktop DESTINATION /etc/xdg/autostart/ )
......@@ -24,5 +26,7 @@ else()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/terminus_autorun.desktop DESTINATION ${CONFIG_HOME}/autostart )
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/com.rastersoft.terminus.service.base ${CMAKE_CURRENT_BINARY_DIR}/com.rastersoft.terminus.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/com.rastersoft.terminus.service DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services/)
include(GSettings)
add_schema(org.rastersoft.terminus.gschema.xml)
[D-BUS Service]
Name=com.rastersoft.terminus
Exec=@DBUS_PREFIX@/bin/terminus
#!/bin/sh
dbus-send --session --print-reply --dest=com.rastersoft.terminus /com/rastersoft/terminus com.rastersoft.terminus.SwapGuake
......@@ -7,4 +7,5 @@ src/settings.vala
src/terminal.vala
src/terminus.vala
src/window.vala
src/checkwayland.c
data/interface/properties.ui
......@@ -49,18 +49,28 @@ set (APP_SOURCES ${APP_SOURCES} terminal.vala)
set (APP_SOURCES ${APP_SOURCES} terminus.vala)
set (APP_SOURCES ${APP_SOURCES} window.vala)
set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_SOURCE_DIR}/src/checkwayland.vapi)
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --vapidir=${CMAKE_SOURCE_DIR}/src/vapidir )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 " )
if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(COMPILE_OPTIONS ${COMPILE_OPTIONS} "-g")
endif()
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --gresources=${CMAKE_SOURCE_DIR}/data/extras.gresource.xml )
vala_precompile(VALA_C terminus
${APP_SOURCES}
PACKAGES
${VALA_PACKAGES}
CUSTOM_VAPIS
${CUSTOM_VAPIS_LIST}
OPTIONS
${COMPILE_OPTIONS}
)
set (VALA_C ${VALA_C} checkwayland.c)
SET (VALA_C ${VALA_C} ${extras_gresource_xml_C_FILE})
add_executable(terminus ${VALA_C})
add_dependencies (terminus extras_gresource_xml)
......
......@@ -31,12 +31,16 @@ namespace Terminus {
class Bindkey : Object {
private string? key;
private bool use_bindkey;
public signal void show_guake();
public Bindkey() {
public Bindkey(bool use_bindkey) {
Keybinder.init();
this.use_bindkey = use_bindkey;
if (this.use_bindkey) {
Keybinder.init();
}
this.key = null;
}
......@@ -44,23 +48,31 @@ namespace Terminus {
bool retval;
if (this.key != null) {
this.unset_bindkey();
if (this.use_bindkey) {
if (this.key != null) {
this.unset_bindkey();
}
}
this.key = key;
retval = Keybinder.bind(key,Terminus.keybind_cb,this);
if (retval == false) {
print("Failed to set the guake_mode bind key\n");
if (this.use_bindkey) {
retval = Keybinder.bind(key,Terminus.keybind_cb,this);
if (retval == false) {
print("Failed to set the guake_mode bind key\n");
}
return retval;
} else {
return true;
}
return retval;
}
public void unset_bindkey() {
if (this.key == null) {
return;
if (this.use_bindkey) {
if (this.key == null) {
return;
}
Keybinder.unbind(this.key,Terminus.keybind_cb);
this.key = null;
}
Keybinder.unbind(this.key,Terminus.keybind_cb);
this.key = null;
}
}
}
#include "gdk/gdk.h"
#include "gdk/gdkwayland.h"
int check_wayland() {
if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
return 1;
} else {
return 0;
}
}
public int check_wayland();
......@@ -21,9 +21,9 @@ using Gee;
//project version = 0.4.0
namespace Terminus {
TerminusRoot main_root;
GLib.Settings settings = null;
GLib.Settings keybind_settings = null;
Terminus.Bindkey bindkey;
......@@ -38,6 +38,7 @@ namespace Terminus {
public TerminusRoot(string[] argv) {
main_root = this;
this.guake_terminal = null;
this.guake_window = null;
......@@ -78,13 +79,21 @@ namespace Terminus {
Terminus.keybind_settings.changed.connect(this.keybind_settings_changed);
if (launch_terminal || launch_guake) {
Bus.own_name (BusType.SESSION, "com.rastersoft.terminus", BusNameOwnerFlags.NONE, this.on_bus_aquired, () => {}, () => {});
Gtk.main();
}
}
void on_bus_aquired (DBusConnection conn) {
try {
conn.register_object ("/com/rastersoft/terminus", new RemoteControl ());
} catch (IOError e) {
GLib.stderr.printf ("Could not register service\n");
}
}
public void keybind_settings_changed(string key) {
print("Cambio %s\n".printf(key));
if (key != "guake-mode") {
return;
}
......@@ -144,6 +153,14 @@ namespace Terminus {
}
public void show_hide() {
this.show_hide_global(2);
}
public void show_hide_global(int mode) {
/*mode = 0: force show
*mode = 1: force hide
*mode = 2: hide if visible, show if hidden
*/
if (Terminus.settings.get_boolean("enable-guake-mode") == false) {
return;
......@@ -154,11 +171,53 @@ namespace Terminus {
}
if (this.guake_window.visible) {
this.guake_window.hide();
if ((mode == 1) || (mode == 2)) {
this.guake_window.hide();
}
} else {
this.guake_window.present();
if ((mode == 0) || (mode == 2)) {
this.guake_window.present();
}
}
}
}
bool check_params(string[] argv) {
int param_counter = 0;
if (check_wayland() == 1) {
return false; // under Wayland we can't use bindkeys
}
while(param_counter < argv.length) {
param_counter++;
if (argv[param_counter] == "--nobindkey") {
return false;
}
}
return true;
}
[DBus (name = "com.rastersoft.terminus")]
public class RemoteControl : GLib.Object {
public int do_ping(int v) {
return (v+1);
}
public void show_guake() {
main_root.show_hide_global(0);
}
public void hide_guake() {
main_root.show_hide_global(1);
}
public void swap_guake() {
main_root.show_hide_global(2);
}
}
}
......@@ -171,12 +230,11 @@ int main(string[] argv) {
Gtk.init(ref argv);
Terminus.settings = new GLib.Settings("org.rastersoft.terminus");
Terminus.keybind_settings = new GLib.Settings("org.rastersoft.terminus.keybindings");
Terminus.bindkey = new Terminus.Bindkey();
Terminus.bindkey = new Terminus.Bindkey(Terminus.check_params(argv));
var tm = new Terminus.TerminusRoot(argv);
new Terminus.TerminusRoot(argv);
return 0;
}
### AutoVala Project ###
autovala_version: 21
autovala_version: 24
project_name: terminus
vala_version: 0.30
......@@ -7,11 +7,10 @@ vala_version: 0.30
*vapidir: src/vapidir
vala_binary: src/terminus
*version: 0.4.0
compile_c_options: -O2
use_gresource: extras_gresource_xml
vala_vapi: checkwayland.vapi
*vala_package: posix
*vala_check_package: atk
*vala_check_package: cairo
......@@ -36,28 +35,35 @@ use_gresource: extras_gresource_xml
*vala_source: terminal.vala
*vala_source: terminus.vala
*vala_source: window.vala
*c_source: checkwayland.c
*po: po
*translate: glade data/interface/properties.ui
*translate: vala src/PanedPercentage.vala
*translate: vala src/base.vala
*translate: vala src/bindkeys.vala
*translate: vala src/notetab.vala
*translate: vala src/terminus.vala
*translate: vala src/terminal.vala
*translate: c src/checkwayland.c
*translate: vala src/container.vala
*translate: vala src/notetab.vala
*translate: vala src/settings.vala
*translate: vala src/terminal.vala
*translate: vala src/terminus.vala
*translate: vala src/window.vala
*translate: glade data/interface/properties.ui
*data: data/local
*doc: doc
*binary: data/terminus_showhide.sh
*desktop: data/terminus.desktop
*autostart: data/terminus_autorun.desktop
*dbus_service: data/com.rastersoft.terminus.service.base
*scheme: data/org.rastersoft.terminus.gschema.xml
*full_icon: Hicolor Applications data/icons/terminus.svg
......
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