Browse Source

Remove libunique dependency

libunique-3.0 should not be used in Gtk3 application anymore.
Its functionality was replaced by Gtk.Application.
Moreover, the argument 1-5 now looks the displayed layer
again changes by key events.
master
Olaf Schulz 2 years ago
parent
commit
264804d174
10 changed files with 272 additions and 350 deletions
  1. +10
    -10
      Makefile
  2. +70
    -0
      src/app.vala
  3. +22
    -22
      src/config-manager.vala
  4. +28
    -28
      src/indicator.vala
  5. +44
    -89
      src/main.vala
  6. +94
    -68
      src/neo-window.vala
  7. +4
    -2
      src/tray.vala
  8. +0
    -29
      src/unique.vala
  9. +0
    -8
      vapi/unique-3.0.deps
  10. +0
    -94
      vapi/unique-3.0.vapi

+ 10
- 10
Makefile View File

@ -18,7 +18,7 @@ PREFIX = /usr/local
APPNAME = NeoLayoutViewer
GIT_COMMIT_VERSION=$(shell git log --oneline --max-count=1 | head --bytes=7)
RELEASE_VERSION=1.2
RELEASE_VERSION=1.3
ENV_FILE=.build_env
# compiler options for a debug build
@ -72,18 +72,18 @@ VAPIDIR = --vapidir=vapi/
# Source files
SRC = src/version.vala \
src/main.vala \
src/neo-window.vala \
src/config-manager.vala
src/main.vala \
src/app.vala \
src/neo-window.vala \
src/config-manager.vala
ifeq ($(WIN),)
VALAC_DEBUG_OPTS += -D _NO_WIN
VALAC_RELEASE_OPTS += -D _NO_WIN
SRC += src/key-overlay.vala \
src/unique.vala \
src/keybinding-manager.vala \
csrc/keysend.c \
csrc/checkModifier.c
src/keybinding-manager.vala \
csrc/keysend.c \
csrc/checkModifier.c
endif
# Asset files
@ -102,7 +102,7 @@ else
endif
# Packages
PKGS = --pkg x11 --pkg keysym --pkg gtk+-3.0 --pkg gee-$(GEEVERSION) --pkg gdk-x11-3.0 --pkg posix --pkg unique-3.0 --pkg gdk-3.0
PKGS = --pkg x11 --pkg keysym --pkg gtk+-3.0 --pkg gee-$(GEEVERSION) --pkg gdk-x11-3.0 --pkg posix --pkg gdk-3.0
# Add some args if tray icon is demanded.
ifeq ($(ICON),tray)
@ -182,7 +182,7 @@ build_release: $(SRC) "$(BINDIR)"
build_release2: $(SRC) "$(BINDIR)"
$(VALAC) --ccode $(VAPIDIR) $(VALAC_RELEASE_OPTS) $(SRC) $(PKGS) $(CC_INCLUDES)
gcc $(SRC:.vala=.c) $(CC_INCLUDES) -o "$(BINDIR)/$(BINNAME)$(BINEXT)" \
`pkg-config --cflags --libs gtk+-3.0 gee-$(GEEVERSION) unique-3.0`
`pkg-config --cflags --libs gtk+-3.0 gee-$(GEEVERSION)`
man: man/neo_layout_viewer.1.gz


+ 70
- 0
src/app.vala View File

@ -0,0 +1,70 @@
using Gtk;
namespace NeoLayoutViewer{
public class NeoLayoutViewerApp: Gtk.Application {
public NeoWindow neo_win = null;
#if tray
public AppStatusIcon neo_tray; //for gnome2.x, kde(?)
#endif
#if indicator
public NeoIndicator neo_indicator; //for gnome3.x
#endif
#if _NO_WIN
public KeybindingManager manager;
#endif
public int start_layer = 0; // > 0: keybord events do not change displayed layer
public ConfigManager configm;
public NeoLayoutViewerApp(ConfigManager configm) {
Object(application_id: "org.gnome.neo_layout_viewer",
flags: ApplicationFlags.HANDLES_OPEN );
this.configm = configm;
}
protected override void activate () {
if (this.neo_win == null ) {
// Create the window of this application and show it
this.neo_win = new NeoWindow (this);
#if tray
this.neo_tray = new AppStatusIcon(neo_win);
#endif
#if indicator
this.neo_indicator = new NeoIndicator(neo_win);
#endif
#if _NO_WIN
manager = new KeybindingManager(this.neo_win);
manager.bind(configm.getConfig().get("show_shortcut"), ()=>{this.neo_win.toggle();});
manager.bind(configm.getConfig().get("move_shortcut"), ()=>{this.neo_win.numkeypad_move(0);});
#endif
this.add_window(this.neo_win);
}else{
// reached if app.activate() called by remote instance
this.neo_win.toggle();
}
}
public override void open (File[] files, string hint) {
// Threat non-option argument(s) as layer to show at startup.
// Note: This signal is not called in remote-case.
foreach (File file in files) {
var slayer = file.get_basename();
this.start_layer = int.parse(slayer);
break;
}
this.activate(); // init neo_win
this.neo_win.show();
}
}
}

+ 22
- 22
src/config-manager.vala View File

@ -3,8 +3,8 @@ namespace NeoLayoutViewer {
public class ConfigManager {
public Gee.Map<string,string> config;
private Gee.Map<string,string> description; // allow optional commenting config entrys.
public Gee.Map<string, string> config;
private Gee.Map<string, string> description; // allow optional commenting config entrys.
public string used_config_path;
public ConfigManager(string[] paths, string conffile) {
@ -79,25 +79,25 @@ namespace NeoLayoutViewer {
if it was not found.
*/
public void add_defaults(){
//config.set("show_shortcut","<Mod4><Super_L>n", "Toggle the visibility of the window.");
addSetting("show_shortcut","<Ctrl><Alt>q", "Toggle the visibility of the window.");
addSetting("on_top","1", "Show window on top.");
addSetting("position","3", "Window position on startup (num pad orientation)");
//config.set("show_shortcut", "<Mod4><Super_L>n", "Toggle the visibility of the window.");
addSetting("show_shortcut", "<Ctrl><Alt>q", "Toggle the visibility of the window.");
addSetting("on_top", "1", "Show window on top.");
addSetting("position", "3", "Window position on startup (num pad orientation)");
/* width of application window
if value between 'resolution width'*max_width and 'resolution width'*min_width */
addSetting("width","1000","Width in Pixel. Min_width and max_width bound sensible values. ");
addSetting("min_width","0.25", "Minimal width. 1=full screen width");
addSetting("max_width","0.5", "Maximal width. 1=full screen width");
addSetting("move_shortcut","<Ctrl><Alt>n", "Circle through window posisitions.");
addSetting("position_cycle","2 3 6 1 3 9 4 7 8", "List of positions (num pad orientation)\n# The n-th number marks the next position of the window.\n# To limit the used positions to screen corners use\n#position_cycle = 3 3 9 1 3 9 1 7 7");
addSetting("display_numpad","1", null);
addSetting("display_function_keys","0", null);
addSetting("window_selectable","0","Disable window selection to use the program as virtual keyboard.");
addSetting("window_decoration","0","Show window decoration/border (not recommended).");
addSetting("screen_width","auto", "Set the resolution of your screen manually, if the automatic detection fails.");
addSetting("screen_height","auto", "Set the resolution of your screen manually, if the automatic detection fails.");
addSetting("show_on_startup","1", "Show window on startup.");
addSetting("asset_folder","./assets", "Default lookup folder image data.");
addSetting("width", "1000", "Width in Pixel. Min_width and max_width bound sensible values. ");
addSetting("min_width", "0.25", "Minimal width. 1=full screen width");
addSetting("max_width", "0.5", "Maximal width. 1=full screen width");
addSetting("move_shortcut", "<Ctrl><Alt>n", "Circle through window posisitions.");
addSetting("position_cycle", "2 3 6 1 3 9 4 7 8", "List of positions (num pad orientation)\n# The n-th number marks the next position of the window.\n# To limit the used positions to screen corners use\n#position_cycle = 3 3 9 1 3 9 1 7 7");
addSetting("display_numpad", "1", null);
addSetting("display_function_keys", "0", null);
addSetting("window_selectable", "0", "Disable window selection to use the program as virtual keyboard.");
addSetting("window_decoration", "0", "Show window decoration/border (not recommended).");
addSetting("screen_width", "auto", "Set the resolution of your screen manually, if the automatic detection fails.");
addSetting("screen_height", "auto", "Set the resolution of your screen manually, if the automatic detection fails.");
addSetting("show_on_startup", "1", "Show window on startup.");
addSetting("asset_folder", "./assets", "Default lookup folder image data.");
}
/*
@ -105,8 +105,8 @@ namespace NeoLayoutViewer {
intern values overrides external values.
*/
private void add_intern_values() {
config.set("numpad_width","350");
config.set("function_keys_height","30");
config.set("numpad_width", "350");
config.set("function_keys_height", "30");
}
private bool search_config_file(string conffile) {
@ -166,7 +166,7 @@ namespace NeoLayoutViewer {
split = regex.split(line);
if(split.length>1){
this.config.set(split[0].strip(),split[1].strip());
this.config.set(split[0].strip(), split[1].strip());
}
}
} catch (GLib.IOError e) {


+ 28
- 28
src/indicator.vala View File

@ -44,43 +44,43 @@ namespace NeoLayoutViewer {
menuMain.append(menuAbout);
var menuQuit = new ImageMenuItem.from_stock(Stock.QUIT, null);
menuQuit.activate.connect(Gtk.main_quit);
menuQuit.activate.connect(NeoLayoutViewer.quit);
menuMain.append(menuQuit);
#else
var anzeigenBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var anzeigenLabel = new Gtk.Label.with_mnemonic("A_nzeigen");
var anzeigenMenuItem = new Gtk.MenuItem();
//anzeigenBox.add(anzeigenIcon);
anzeigenLabel.set_xalign(0.0f);
anzeigenBox.pack_end(anzeigenLabel, true, true, 0);
anzeigenMenuItem.add(anzeigenBox);
var anzeigenBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var anzeigenLabel = new Gtk.Label.with_mnemonic("A_nzeigen");
var anzeigenMenuItem = new Gtk.MenuItem();
//anzeigenBox.add(anzeigenIcon);
anzeigenLabel.set_xalign(0.0f);
anzeigenBox.pack_end(anzeigenLabel, true, true, 0);
anzeigenMenuItem.add(anzeigenBox);
anzeigenMenuItem.activate.connect(() => { this.neo_win.toggle(); });
menuMain.append(anzeigenMenuItem);
menuMain.append(anzeigenMenuItem);
var aboutBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var aboutBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var aboutIcon = new Gtk.Image.from_icon_name( "help-about", IconSize.SMALL_TOOLBAR);
var aboutLabel = new Gtk.Label.with_mnemonic("_About");
var aboutMenuItem = new Gtk.MenuItem();
aboutLabel.set_use_underline(true);
aboutLabel.set_xalign(0.0f);
aboutBox.pack_start(aboutIcon, false, false, 0);
aboutBox.pack_end(aboutLabel, true, true, 0);
aboutMenuItem.add(aboutBox);
var aboutLabel = new Gtk.Label.with_mnemonic("_About");
var aboutMenuItem = new Gtk.MenuItem();
aboutLabel.set_use_underline(true);
aboutLabel.set_xalign(0.0f);
aboutBox.pack_start(aboutIcon, false, false, 0);
aboutBox.pack_end(aboutLabel, true, true, 0);
aboutMenuItem.add(aboutBox);
aboutMenuItem.activate.connect(NeoLayoutViewer.about_dialog);
menuMain.append(aboutMenuItem);
menuMain.append(aboutMenuItem);
var quitBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var quitBox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 2);
var quitIcon = new Gtk.Image.from_icon_name( "application-exit", IconSize.SMALL_TOOLBAR);
var quitLabel = new Gtk.Label.with_mnemonic("_QUIT");
var quitMenuItem = new Gtk.MenuItem();
quitLabel.set_use_underline(true);
quitLabel.set_xalign(0.0f);
quitBox.pack_start(quitIcon, false, false, 0);
quitBox.pack_end(quitLabel, true, true, 0);
quitMenuItem.add(quitBox);
quitMenuItem.activate.connect(Gtk.main_quit);
menuMain.append(quitMenuItem);
var quitLabel = new Gtk.Label.with_mnemonic("_QUIT");
var quitMenuItem = new Gtk.MenuItem();
quitLabel.set_use_underline(true);
quitLabel.set_xalign(0.0f);
quitBox.pack_start(quitIcon, false, false, 0);
quitBox.pack_end(quitLabel, true, true, 0);
quitMenuItem.add(quitBox);
quitMenuItem.activate.connect(NeoLayoutViewer.quit);
menuMain.append(quitMenuItem);
#endif
menuMain.show_all();


+ 44
- 89
src/main.vala View File

@ -2,49 +2,18 @@ using X;
namespace NeoLayoutViewer{
public NeoWindow neo_win;
#if _NO_WIN
public KeybindingManager manager;
#endif
public ConfigManager configm;
#if tray
public AppStatusIcon neo_tray; //for gnome2.x, kde(?)
#endif
#if indicator
public NeoIndicator neo_indicator; //for gnome3.x
#endif
public NeoLayoutViewerApp app;
public static int main(string[] args) {
string slayer;
if (args.length < 2) {
slayer = "1";
} else {
slayer = args[1];
}
Gtk.init(ref args);
//Get program path (no binding for getcwd found…)
string path = "";
try {
var regex = new Regex("[^/]*$");
path = regex.replace(args[0],-1,0,"");
} catch (RegexError e) {
path = "";
}
debug(@"Path: $path");
string[] paths = {
GLib.Environment.get_user_config_dir(),
GLib.Environment.get_home_dir(),
GLib.Environment.get_current_dir(),
};
configm = new ConfigManager(paths,"neo_layout_viewer.conf");
configm = new ConfigManager(paths, "neo_layout_viewer.conf");
// Try to find asset folder (images)
string asset_folder = search_asset_folder( configm.getConfig().get("asset_folder") );
@ -53,61 +22,47 @@ namespace NeoLayoutViewer{
stdout.flush();
return 0;
}
//add path to asset folder
configm.getConfig().set("asset_folder",asset_folder);
// Update asset folder in config
configm.getConfig().set("asset_folder", asset_folder);
debug(@"Asset folder: $(asset_folder)\n");
// Init application window.
app = new NeoLayoutViewerApp (configm);
neo_win = new NeoWindow (slayer, configm.getConfig());
#if _NO_WIN
var app = showPreviousInstance("org.gnome.neo_layout_viewer", neo_win);
if (app == null) {
return 0;
try {
app.register(); // returns false if and only if throws Error
} catch (Error e) {
debug(@"Gtk.Application.register() failed.\n");
return -1;
}
if (app.is_remote) {
print(@"Application is already running.\n");
app.activate();
}else{
return app.run(args);
}
#endif
#if _NO_WIN
manager = new KeybindingManager(neo_win);
#endif
#if tray
neo_tray = new AppStatusIcon(neo_win);
#endif
#if indicator
neo_indicator = new NeoIndicator(neo_win);
#endif
#if _NO_WIN
manager.bind(configm.getConfig().get("show_shortcut"), ()=>{neo_win.toggle();});
manager.bind(configm.getConfig().get("move_shortcut"), ()=>{neo_win.numkeypad_move(0);});
#endif
//move window (Fehlerquelle: config von configm ist im allgemeinen nicht gleich neo_win.config?! Derzeit gleiches Objekt.)
Gtk.main();
return 0;
}
private static void quit() {
app.quit(); // stops app.run()
}
/* This function create the about dialog in
tray menu or indicator menu */
private static void about_dialog() {
var about = new Gtk.AboutDialog();
about.set_logo(neo_win.getIcon());
about.set_destroy_with_parent (true);
about.set_transient_for (neo_win);
about.set_version(@"$(RELEASE_VERSION) (git $(GIT_COMMIT_VERSION)) )");
about.set_program_name("Neo2.0 Ebenenanzeige");
about.set_comments("""Erleichtert das Nachschlagen von Tastenkombinationen im Neo 2.0-Layout.
/* This function create the about dialog in
tray menu or indicator menu */
var about = new Gtk.AboutDialog();
about.set_logo(app.neo_win.getIcon());
about.set_destroy_with_parent (true);
about.set_transient_for (app.neo_win);
about.set_version(@"$(RELEASE_VERSION) (git $(GIT_COMMIT_VERSION)) )");
about.set_program_name("Neo2.0 Ebenenanzeige");
about.set_comments("""Erleichtert das Nachschlagen von Tastenkombinationen im Neo 2.0-Layout.
Olaf Schulz
funwithkinect-AT-googlemail.com
funwithkinect@googlemail.com
Tastenkombinationen:
@ -117,26 +72,26 @@ Tastenkombinationen:
Verwendete Konfigurationsdatei:
%s""".printf(
neo_win.config.get("show_shortcut"),
neo_win.config.get("move_shortcut"),
app.neo_win.config.get("show_shortcut"),
app.neo_win.config.get("move_shortcut"),
configm.used_config_path)
);
about.set_copyright("LGPLv3");
center_window(about);
about.run();
about.hide();
about.destroy();
);
about.set_copyright("LGPLv3");
center_window(about);
about.run();
about.hide();
about.destroy();
}
}
private void center_window(Gtk.Window win){
int screen_width = neo_win.get_screen_width();
int screen_height = neo_win.get_screen_height();
int x,y,w,h;
int screen_width = app.neo_win.get_screen_width();
int screen_height = app.neo_win.get_screen_height();
int x, y, w, h;
win.get_size(out w, out h);
x = (screen_width - w) / 2;
y = (screen_height - h) / 2;
win.move(x,y);
win.move(x, y);
}
/* Check given path and shared files folders for the asset folder.
@ -144,7 +99,7 @@ Tastenkombinationen:
@return: assed folder or null.
*/
private static string? search_asset_folder(string path){
const string filename = "/icons/Neo-Icon.png";
/*const*/ string filename = "/icons/Neo-Icon.png";
string[] paths = {
path, // path from config file


+ 94
- 68
src/neo-window.vala View File

@ -27,7 +27,7 @@ namespace NeoLayoutViewer {
}
}
public class NeoWindow : Gtk.Window {
public class NeoWindow : Gtk.ApplicationWindow {
private Gtk.Image image;
public Gtk.Label status;
@ -35,7 +35,12 @@ namespace NeoLayoutViewer {
public Gee.List<Modkey> modifier_key_images; // for modifier which didn't toggle a layout layer. I.e. ctrl, alt.
public Gee.Map<string, string> config;
public int layer;
public bool fix_layer = false;
private int _layer = 1;
public int layer {
get { return _layer; }
set { if (value < 1 || value > 6) { _layer = 1; }else{ _layer = value; } }
}
public int[] active_modifier_by_keyboard;
public int[] active_modifier_by_mouse;
public int numpad_width;
@ -54,51 +59,61 @@ namespace NeoLayoutViewer {
/* Falls ein Modifier (oder eine andere Taste) gedrückt wird und schon Modifier gedrückt sind, gibt die Map an, welche Ebene dann aktiviert ist. */
private short[,] MODIFIER_MAP = {
{0,1,2,3,4,5},
{1,1,4,3,4,5},
{2,4,2,5,4,5},
{3,3,5,3,4,5} };
{0, 1, 2, 3, 4, 5},
{1, 1, 4, 3, 4, 5},
{2, 4, 2, 5, 4, 5},
{3, 3, 5, 3, 4, 5} };
/* [0,1]^3->{0,5}, Bildet aktive Modifier auf angezeigte Ebene ab.
Interpretationsreihenfolge der Dimensionen: Shift,Neo-Mod3, Neo-Mod4. */
/* [0, 1]^3->{0, 5}, Bildet aktive Modifier auf angezeigte Ebene ab.
Interpretationsreihenfolge der Dimensionen: Shift, Neo-Mod3, Neo-Mod4. */
private short[,,] MODIFIER_MAP2 = {
{ {0 , 3}, {2 , 5 } }, // 000, 001; 010, 011
{ {1 , 3}, {4 , 5}} // 100, 101; 110, 111
};
/* {0, 5} -> [0, 1]^3 */
private short[,] LAYER_TO_MODIFIERS = {
{0 , 0, 0}, // 0
{1 , 0, 0}, // 1
{0 , 1, 0}, // 2
{0 , 0, 1}, // 3
{1 , 1, 0}, // 4
{1 , 1, 1} // 5
};
/* Analog zu oben für den Fall, dass eine Taste losgelassen wird. Funktioniert nicht immer.
Ist beispielsweise ShiftL und ShiftR gedrückt und eine wird losgelassen, so wechselt die Anzeige zur ersten Ebene.
Die Fehler sind imo zu vernachlässigen.
*/
private short[,] MODIFIER_MAP_RELEASE = {
{0,0,0,0,0,0},
{0,0,2,3,2,5},
{0,1,0,3,1,3},
{0,1,2,0,4,2} };
{0, 0, 0, 0, 0, 0},
{0, 0, 2, 3, 2, 5},
{0, 1, 0, 3, 1, 3},
{0, 1, 2, 0, 4, 2} };
/*
Modifier können per Tastatur und Maus aktiviert werden. Diese Abbildung entscheidet,
wie bei einer Zustandsänderung verfahren werden soll.
k,m,K,M ∈ {0,1}.
k, m, K, M ∈ {0, 1}.
k - Taste wurde gedrückt gehalten
m - Taste wurde per Mausklick selektiert.
K - Taste wird gedrückt
M - Taste wird per Mausklick selektiert.
k' = f(k,m,K,M). Und wegen der Symmetrie(!)
m' = f(m,k,M,K)
k' = f(k, m, K, M). Und wegen der Symmetrie(!)
m' = f(m, k, M, K)
Siehe auch change_active_modifier(…).
*/
private short[,,,] MODIFIER_KEYBOARD_MOUSE_MAP = {
// k = f(k,m,K,M,) and m = f(m,k,M,K)
{ { {0, 0} , {1, 0} } , // 0000, 0001; 0010, 0011;
{ {0, 0} , {1, 1} } }, // 0100, 0101; 0110, 0111(=swap);
// k = f(k, m, K, M, ) and m = f(m, k, M, K)
{ { {0, 0} , {1, 0} } , // 0000, 0001; 0010, 0011;
{ {0, 0} , {1, 1} } }, // 0100, 0101; 0110, 0111(=swap);
{ { {0, 0} , {1, 0} } , //1000, 1001; 1010, 1011(=swap);
{ {0, 0} , {1, 1} } }//1100, 1101; 1110, 1111; //k=m=1 should be impossible
};
public NeoWindow (string slayer, Gee.Map<string, string> config) {
this.config = config;
public NeoWindow (NeoLayoutViewerApp app) {
this.config = app.configm.getConfig();
this.minimized = true;
/* Set window type to let tiling window manager the chance
@ -118,51 +133,54 @@ namespace NeoLayoutViewer {
this.MODIFIER_MASK = {
0,
Gdk.ModifierType.SHIFT_MASK, //1
Gdk.ModifierType.MOD5_MASK,//128
Gdk.ModifierType.MOD5_MASK, //128
Gdk.ModifierType.MOD3_MASK, //32
Gdk.ModifierType.CONTROL_MASK,
Gdk.ModifierType.MOD1_MASK // Alt-Mask do not work :-(
};
this.active_modifier_by_keyboard = {0,0,0,0,0,0};
this.active_modifier_by_mouse = {0,0,0,0,0,0};
this.active_modifier_by_keyboard = {0, 0, 0, 0, 0, 0};
this.active_modifier_by_mouse = {0, 0, 0, 0, 0, 0};
this.modifier_key_images = new Gee.ArrayList<Modkey>();
this.position_num = int.max(int.min(int.parse(config.get("position")),9),1);
this.position_num = int.max(int.min(int.parse(this.config.get("position")), 9), 1);
//Anlegen des Arrays, welches den Positionsdurchlauf beschreibt.
try {
var space = new Regex(" ");
string[] split = space.split(config.get("position_cycle"));
position_cycle = new int[int.max(9,split.length)];
string[] split = space.split(this.config.get("position_cycle"));
position_cycle = new int[int.max(9, split.length)];
for (int i = 0;i < split.length; i++) {
position_cycle[i] = int.max(int.min(int.parse(split[i]),9),1);//Zulässiger Bereich: 1-9
position_cycle[i] = int.max(int.min(int.parse(split[i]), 9), 1);//Zulässiger Bereich: 1-9
}
} catch (RegexError e) {
position_cycle = {3,3,9,1,3,9,1,7,7};
position_cycle = {3, 3, 9, 1, 3, 9, 1, 7, 7};
}
this.layer = int.parse(slayer);
if (this.layer < 1 || this.layer > 6) { this.layer = 1; }
if (app.start_layer > 0 ){
this.fix_layer = true;
this.layer = app.start_layer;
this.active_modifier_by_mouse[1] = this.LAYER_TO_MODIFIERS[this.layer-1, 0];
this.active_modifier_by_mouse[2] = this.LAYER_TO_MODIFIERS[this.layer-1, 1];
this.active_modifier_by_mouse[3] = this.LAYER_TO_MODIFIERS[this.layer-1, 2];
}
// Crawl dimensions of screen/display/monitor
// Should be done before load_image_buffer() is called.
screen_dim_auto[0] = (config.get("screen_width") == "auto");
screen_dim_auto[1] = (config.get("screen_height") == "auto");
screen_dim_auto[0] = (this.config.get("screen_width") == "auto");
screen_dim_auto[1] = (this.config.get("screen_height") == "auto");
if (screen_dim_auto[0]) {
this.screen_dim[0] = this.get_screen_width();
this.screen_dim_auto[0] = false; // Disables further re-evaluations
} else {
this.screen_dim[0] = int.max(1, int.parse(config.get("screen_width")));
this.screen_dim[0] = int.max(1, int.parse(this.config.get("screen_width")));
}
if(screen_dim_auto[1]) {
this.screen_dim[1] = this.get_screen_height();
this.screen_dim_auto[1] = false; // Disables further re-evaluations
} else {
this.screen_dim[1] = int.max(1, int.parse(config.get("screen_height")));
this.screen_dim[1] = int.max(1, int.parse(this.config.get("screen_height")));
}
@ -196,42 +214,42 @@ namespace NeoLayoutViewer {
//Fenstereigenschaften setzen
this.key_press_event.connect(on_key_pressed);
this.button_press_event.connect(on_button_pressed);
this.destroy.connect(Gtk.main_quit);
this.destroy.connect(NeoLayoutViewer.quit);
//this.set_gravity(Gdk.Gravity.SOUTH);
this.decorated = (config.get("window_decoration") != "0");
this.decorated = (this.config.get("window_decoration") != "0");
this.skip_taskbar_hint = true;
//Icon des Fensters
this.icon = this.image_buffer[0];
//Nicht selektierbar (für virtuelle Tastatur)
this.set_accept_focus((config.get("window_selectable") != "0"));
this.set_accept_focus((this.config.get("window_selectable") != "0"));
if( this.config.get("show_on_startup") != "0" ){
//Move ist erst nach show() erfolgreich
this.numkeypad_move(int.parse(config.get("position")));
this.numkeypad_move(int.parse(this.config.get("position")));
this.show();
}else{
this.hide();
this.numkeypad_move(int.parse(config.get("position")));
this.numkeypad_move(int.parse(this.config.get("position")));
}
}
public override void show() {
this.minimized = false;
this.move(this.position_on_hide_x,this.position_on_hide_y);
this.move(this.position_on_hide_x, this.position_on_hide_y);
debug(@"Show window on $(this.position_on_hide_x), $(this.position_on_hide_y)\n");
base.show();
this.move(this.position_on_hide_x,this.position_on_hide_y);
this.move(this.position_on_hide_x, this.position_on_hide_y);
/* Second move fixes issue for i3-wm(?). The move() before show()
moves the current window as expected, but somehow does not propagate this values
correcty to the wm. => The next hide() call will fetch wrong values
and a second show() call plaes the window in the middle of the screen.
*/
if (config.get("on_top") == "1") {
if (this.config.get("on_top") == "1") {
this.set_keep_above(true);
} else {
this.present();
@ -267,7 +285,7 @@ namespace NeoLayoutViewer {
int screen_width = this.get_screen_width();
int screen_height = this.get_screen_height();
int x,y,w,h;
int x, y, w, h;
this.get_size(out w, out h);
switch(pos) {
@ -319,7 +337,7 @@ namespace NeoLayoutViewer {
this.position_on_hide_y = y;
this.move(x,y);
this.move(x, y);
}
public Gdk.Pixbuf open_image (int layer) {
@ -342,26 +360,26 @@ namespace NeoLayoutViewer {
int screen_width = this.get_screen_width(); //Gdk.Screen.width();
int max_width = (int) (double.parse(this.config.get("max_width")) * screen_width);
int min_width = (int) (double.parse(this.config.get("min_width")) * screen_width);
int width = int.min(int.max(int.parse(config.get("width")),min_width),max_width);
int width = int.min(int.max(int.parse(this.config.get("width")), min_width), max_width);
int w, h;
this.numpad_width = int.parse(config.get("numpad_width"));
this.function_keys_height = int.parse(config.get("function_keys_height"));
this.numpad_width = int.parse(this.config.get("numpad_width"));
this.function_keys_height = int.parse(this.config.get("function_keys_height"));
for (int i = 1; i < 7; i++) {
this.image_buffer[i] = open_image(i);
//Funktionstasten ausblennden, falls gefordert.
if (config.get("display_function_keys") == "0") {
var tmp = new Gdk.Pixbuf(image_buffer[i].colorspace,image_buffer[i].has_alpha,image_buffer[i].bits_per_sample, image_buffer[i].width ,image_buffer[i].height-function_keys_height);
this.image_buffer[i].copy_area(0,function_keys_height,tmp.width,tmp.height,tmp,0,0);
if (this.config.get("display_function_keys") == "0") {
var tmp = new Gdk.Pixbuf(image_buffer[i].colorspace, image_buffer[i].has_alpha, image_buffer[i].bits_per_sample, image_buffer[i].width , image_buffer[i].height-function_keys_height);
this.image_buffer[i].copy_area(0, function_keys_height, tmp.width, tmp.height, tmp, 0, 0);
this.image_buffer[i] = tmp;
}
//Numpad-Teil abschneiden, falls gefordert.
if (config.get("display_numpad") == "0") {
var tmp = new Gdk.Pixbuf(image_buffer[i].colorspace,image_buffer[i].has_alpha,image_buffer[i].bits_per_sample, image_buffer[i].width-numpad_width ,image_buffer[i].height);
this.image_buffer[i].copy_area(0,0,tmp.width,tmp.height,tmp,0,0);
if (this.config.get("display_numpad") == "0") {
var tmp = new Gdk.Pixbuf(image_buffer[i].colorspace, image_buffer[i].has_alpha, image_buffer[i].bits_per_sample, image_buffer[i].width-numpad_width , image_buffer[i].height);
this.image_buffer[i].copy_area(0, 0, tmp.width, tmp.height, tmp, 0, 0);
this.image_buffer[i] = tmp;
}
@ -376,7 +394,7 @@ namespace NeoLayoutViewer {
private bool on_key_pressed (Widget source, Gdk.EventKey key) {
// If the key pressed was q, quit, else show the next page
if (key.str == "q") {
Gtk.main_quit ();
NeoLayoutViewer.quit();
}
if (key.str == "h") {
@ -455,12 +473,20 @@ namespace NeoLayoutViewer {
public void redraw() {
var tlayer = this.layer;
this.layer = this.MODIFIER_MAP2[
this.active_modifier_by_keyboard[1] | this.active_modifier_by_mouse[1], //shift
this.active_modifier_by_keyboard[2] | this.active_modifier_by_mouse[2], //neo-mod3
this.active_modifier_by_keyboard[3] | this.active_modifier_by_mouse[3] //neo-mod4
if (this.fix_layer) { // Ignore key events
this.layer = this.MODIFIER_MAP2[
this.active_modifier_by_mouse[1], //shift
this.active_modifier_by_mouse[2], //neo-mod3
this.active_modifier_by_mouse[3] //neo-mod4
] + 1;
}else{
this.layer = this.MODIFIER_MAP2[
this.active_modifier_by_keyboard[1] | this.active_modifier_by_mouse[1], //shift
this.active_modifier_by_keyboard[2] | this.active_modifier_by_mouse[2], //neo-mod3
this.active_modifier_by_keyboard[3] | this.active_modifier_by_mouse[3] //neo-mod4
] + 1;
}
// check, which extra modifier is pressed and update.
foreach (var modkey in modifier_key_images) {
modkey.change(
@ -511,8 +537,8 @@ namespace NeoLayoutViewer {
this.check_modifier(iet1);
}
public int get_screen_width(){
// Return value derived from config.get("screen_width")) or Gdk.Screen.width()
public int get_screen_width(){
// Return value derived from config.get("screen_width")) or Gdk.Screen.width()
if( this.screen_dim_auto[0] ){
//Re-evaluate
@ -535,11 +561,11 @@ namespace NeoLayoutViewer {
screen_dim[0] = geometry.width;
#endif
}
return screen_dim[0];
}
return screen_dim[0];
}
public int get_screen_height(){
// Return value derived from config.get("screen_height")) or Gdk.Screen.height()
public int get_screen_height(){
// Return value derived from config.get("screen_height")) or Gdk.Screen.height()
if( this.screen_dim_auto[1] ){
//Re-evaluate
@ -562,8 +588,8 @@ namespace NeoLayoutViewer {
screen_dim[1] = geometry.height;
#endif
}
return screen_dim[1];
}
return screen_dim[1];
}
} //End class NeoWindow


+ 4
- 2
src/tray.vala View File

@ -33,7 +33,8 @@ namespace NeoLayoutViewer {
menuMain.append(menuAbout);
var menuQuit = new ImageMenuItem.from_stock(Stock.QUIT, null);
menuQuit.activate.connect(Gtk.main_quit);
//menuQuit.activate.connect(Gtk.main_quit);
menuQuit.activate.connect(NeoLayoutViewer.quit);
menuMain.append(menuQuit);
#else
@ -58,7 +59,8 @@ namespace NeoLayoutViewer {
quitBox.pack_start(quitIcon, false, false, 0);
quitBox.pack_end(quitLabel, true, true, 0);
quitMenuItem.add(quitBox);
quitMenuItem.activate.connect(Gtk.main_quit);
//quitMenuItem.activate.connect(Gtk.main_quit);
quitMenuItem.activate.connect(NeoLayoutViewer.quit);
menuMain.append(quitMenuItem);
#endif


+ 0
- 29
src/unique.vala View File

@ -1,29 +0,0 @@
using Gtk;
using Unique;
namespace NeoLayoutViewer {
public const int SHOW=1000;
public static Unique.App? showPreviousInstance(string name, Gtk.Window win){
var app = new Unique.App(name, null);
app.add_command ("Show application", SHOW);
if( app.is_running ){
//where is already a running instance
debug("Application already running. Show window of other instance.");
app.send_message(SHOW,null);
return null;
}
app.message_received.connect( (t, command, data, time) =>{
if(command == SHOW){
((NeoWindow)win).toggle();
}
return Unique.Response.OK;
});
return app;
}
}

+ 0
- 8
vapi/unique-3.0.deps View File

@ -1,8 +0,0 @@
gio-2.0
cairo
atk
pango
gdk-3.0
gdk-pixbuf-2.0
gtk+-3.0

+ 0
- 94
vapi/unique-3.0.vapi View File

@ -1,94 +0,0 @@
/* unique-1.0.vapi generated by vapigen, do not modify. */
namespace Unique {
[CCode (cheader_filename = "unique/unique.h")]
public class App : GLib.Object {
[CCode (has_construct_function = false)]
public App (string name, string? startup_id);
public void add_command (string command_name, int command_id);
public Unique.Response send_message (int command_id, Unique.MessageData? message_data);
public void watch_window (Gtk.Window window);
[CCode (has_construct_function = false)]
public App.with_commands (string name, string? startup_id, ...);
[NoAccessorMethod]
public bool is_running { get; }
[NoAccessorMethod]
public string name { owned get; construct; }
[NoAccessorMethod]
public Gdk.Screen screen { owned get; set construct; }
[NoAccessorMethod]
public string startup_id { owned get; construct; }
public virtual signal Unique.Response message_received (int command, Unique.MessageData message_data, uint time_);
}
[CCode (cheader_filename = "unique/unique.h")]
public class Backend : GLib.Object {
public weak string name;
public weak Unique.App parent;
public weak Gdk.Screen screen;
public weak string startup_id;
public uint workspace;
[CCode (has_construct_function = false)]
protected Backend ();
public static unowned Unique.Backend create ();
public unowned string get_name ();
public unowned Gdk.Screen get_screen ();
public unowned string get_startup_id ();
public uint get_workspace ();
public virtual bool request_name ();
public virtual Unique.Response send_message (int command_id, Unique.MessageData message_data, uint time_);
public void set_name (string name);
public void set_screen (Gdk.Screen screen);
public void set_startup_id (string startup_id);
}
[CCode (cheader_filename = "unique/unique.h", copy_function = "unique_message_data_copy", type_id = "unique_message_data_get_type ()")]
[Compact]
public class MessageData {
[CCode (has_construct_function = false)]
public MessageData ();
public Unique.MessageData copy ();
public unowned uchar[] @get (size_t length);
public unowned string get_filename ();
public unowned Gdk.Screen get_screen ();
public unowned string get_startup_id ();
public string get_text ();
[CCode (array_length = false)]
public string[] get_uris ();
public uint get_workspace ();
public void @set ([CCode (array_length_type = "gsize")] uchar[]? data);
public void set_filename (string filename);
public bool set_text (string str, ssize_t length);
public bool set_uris ([CCode (array_length = false)] string[] uris);
}
[CCode (cheader_filename = "unique/unique.h", cprefix = "UNIQUE_")]
public enum Command {
INVALID,
ACTIVATE,
NEW,
OPEN,
CLOSE
}
[CCode (cheader_filename = "unique/unique.h", cprefix = "UNIQUE_RESPONSE_")]
public enum Response {
INVALID,
OK,
CANCEL,
FAIL,
PASSTHROUGH
}
[CCode (cheader_filename = "unique/unique.h")]
public const string API_VERSION_S;
[CCode (cheader_filename = "unique/unique.h")]
public const string DEFAULT_BACKEND_S;
[CCode (cheader_filename = "unique/unique.h")]
public const int MAJOR_VERSION;
[CCode (cheader_filename = "unique/unique.h")]
public const int MICRO_VERSION;
[CCode (cheader_filename = "unique/unique.h")]
public const int MINOR_VERSION;
[CCode (cheader_filename = "unique/unique.h")]
public const string PROTOCOL_VERSION_S;
[CCode (cheader_filename = "unique/unique.h")]
public const int VERSION_HEX;
[CCode (cheader_filename = "unique/unique.h")]
public const string VERSION_S;
}

Loading…
Cancel
Save