需要有关 Ubuntu GNOME 17.04 上的 C++ 应用程序的帮助

需要有关 Ubuntu GNOME 17.04 上的 C++ 应用程序的帮助

注意:这可能不是回答这个问题的最佳地方,所以如果有更好的地方,请告诉我。

有一款很棒的应用程序叫做,easystroke它是 X11 的手势识别应用程序。但是,最后一次代码更新是在 2013 年,它在 Ubuntu GNOME 17.04 中存在一些问题。

它仍然可以在 Ubuntu GNOME 17.04 中运行,但我遇到了两个问题。

  1. 它不记得它的一个偏好(显示手势的方法 - XShape)
  2. 编译时出现错误

Wiki 位于https://github.com/thjaeger/easystroke/wiki

代码可以通过以下方式轻松获取:git clone git://github.com/thjaeger/easystroke.git

构建要求和构建说明位于https://github.com/thjaeger/easystroke/wiki/BuildInstructions

你可以用以下方法编译它make -j2

除了一些编译警告之外,这里还有令人震惊的错误......

actions.cc: In constructor ‘TreeViewMulti::TreeViewMulti()’:
actions.cc:57:39: error: ‘group’ is not a member of ‘sigc’
  get_selection()->set_select_function(sigc::group(&negate, sigc::ref(pending)));
                                       ^~~~
Makefile:74: recipe for target 'actions.o' failed
make: *** [actions.o] Error 1
make: *** Waiting for unfinished jobs....

有没有 C++ 人士可以帮忙?

答案1

easystroke 在 Arch 上工作得很好(我自己也在用,来自 repos)。那里的版本是从原始 sourceforge 页面,并且有两个补丁。

第一个补丁用于使用 gcc7 进行构建

From 9e2c32390c5c253aade3bb703e51841748d2c37e Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <[email protected]>
Date: Sat, 28 Jan 2017 01:26:00 +0000
Subject: [PATCH] Remove abs(float) function that clashes with std::abs(float)

Depending on which C++ standard library headers have been included there
might an abs(float) function already declared in the global namespace,
so the definition in this file conflicts with it. This cause a build
failure with GCC 7, which conforms more closely to the C++ standard with
respect to overloads of abs.

Including <cmath> and adding a using-declaration for std::abs ensures
that the standard std::abs(float) function is available. This solution
should be portable to all compilers.
---
 handler.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/handler.cc b/handler.cc
index 8830ea2..685b1ff 100644
--- a/handler.cc
+++ b/handler.cc
@@ -23,6 +23,8 @@
 #include <X11/extensions/XTest.h>
 #include <X11/XKBlib.h>
 #include <X11/Xproto.h>
+#include <cmath>  // std::abs(float)
+using std::abs;

 XState *xstate = nullptr;

@@ -533,8 +535,6 @@ class WaitForPongHandler : public Handler, protected Timeout {
    virtual Grabber::State grab_mode() { return parent->grab_mode(); }
 };

-static inline float abs(float x) { return x > 0 ? x : -x; }
-
 class AbstractScrollHandler : public Handler {
    bool have_x, have_y;
    float last_x, last_y;

第二个是针对你提到的问题

diff -uprb easystroke-0.6.0.orig/actions.cc easystroke-0.6.0/actions.cc
--- easystroke-0.6.0.orig/actions.cc    2013-03-27 17:52:38.000000000 +0200
+++ easystroke-0.6.0/actions.cc 2015-12-07 22:07:17.720041171 +0200
@@ -51,10 +51,11 @@ void TreeViewMulti::on_drag_begin(const
    context->set_icon(pb, pb->get_width(), pb->get_height());
 }

-bool negate(bool b) { return !b; }
-
 TreeViewMulti::TreeViewMulti() : Gtk::TreeView(), pending(false) {
-   get_selection()->set_select_function(sigc::group(&negate, sigc::ref(pending)));
+   get_selection()->set_select_function(
+       [this](Glib::RefPtr<Gtk::TreeModel> const&, Gtk::TreeModel::Path const&, bool) {
+           return !pending;
+       });
 }

 enum Type { COMMAND, KEY, TEXT, SCROLL, IGNORE, BUTTON, MISC };
diff -uprb easystroke-0.6.0.orig/Makefile easystroke-0.6.0/Makefile
--- easystroke-0.6.0.orig/Makefile  2013-03-27 17:52:38.000000000 +0200
+++ easystroke-0.6.0/Makefile   2015-12-07 21:54:47.926776791 +0200
@@ -21,8 +21,7 @@ LOCALEDIR= $(PREFIX)/share/locale
 DFLAGS   =
 OFLAGS   = -O2
 AOFLAGS  = -O3
-STROKEFLAGS  = -Wall -std=c99 $(DFLAGS)
-CXXFLAGS = -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" `pkg-config gtkmm-3.0 dbus-glib-1 --cflags`
+CXXFLAGS = -Wall $(DFLAGS) -std=c++11 -DLOCALEDIR=\"$(LOCALEDIR)\" `pkg-config gtkmm-3.0 dbus-glib-1 --cflags`
 CFLAGS   = -Wall $(DFLAGS) -DLOCALEDIR=\"$(LOCALEDIR)\" `pkg-config gtk+-3.0 --cflags` -DGETTEXT_PACKAGE='"easystroke"'
 LDFLAGS  = $(DFLAGS)

@@ -63,7 +62,7 @@ $(BINARY): $(OFILES)
    $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)

 stroke.o: stroke.c
-   $(CC) $(STROKEFLAGS) $(AOFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<
+   $(CC) $(CFLAGS) $(AOFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<

 %.o: %.c
    $(CC) $(CFLAGS) $(OFLAGS) -MT $@ -MMD -MP -MF $*.Po -o $@ -c $<

AUR 软件包中有 4 个补丁,你可以查看一下这里。您可以从那里下载补丁,也可以单击查看 PKGBUILD 以查看构建说明(其实很简单,应用补丁然后制作)。那个是从 git 构建的,但对于像这样基本上已经死了的项目,我认为 -git 没什么区别。过去 2 年只有一次提交。

答案2

事实证明,https://reviews.freebsd.org/D10815@ravery (谢谢) 建议的结果是 freebsd 的补丁... 但是它确实让我想到其他地方可能有一个可以在 Ubuntu 中使用的补丁。

我最后通过电子邮件和[电子邮件保护]Tobias 给我提供了一个链接https://aur.archlinux.org/cgit/aur.git/plain/sigc.patch?h=easystroke-git&id=3d16f0584c8cf0ade6c181cb56c12d7abe2e17b7在应用补丁后,这将允许 Git 代码进行编译(带有大量警告)patch -p1 -i /path/to/sigc.patch

Fix build with libsigc++ 2.4+ (group was removed).
diff -Naur a/actions.cc b/actions.cc
--- a/actions.cc    2015-11-04 19:56:49.351107678 +0100
+++ b/actions.cc    2015-11-04 19:57:07.161246969 +0100
@@ -51,10 +51,8 @@
    context->set_icon(pb, pb->get_width(), pb->get_height());
 }

-bool negate(bool b) { return !b; }
-
 TreeViewMulti::TreeViewMulti() : Gtk::TreeView(), pending(false) {
-   get_selection()->set_select_function(sigc::group(&negate, sigc::ref(pending)));
+    get_selection()->set_select_function(sigc::mem_fun(*this, &TreeViewMulti::negate_pending));
 }

 enum Type { COMMAND, KEY, TEXT, SCROLL, IGNORE, BUTTON, MISC };
diff -Naur a/actions.h b/actions.h
--- a/actions.h 2015-11-04 19:56:49.351107678 +0100
+++ b/actions.h 2015-11-04 19:57:07.161246969 +0100
@@ -30,6 +30,11 @@
    virtual void on_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context);
 public:
    TreeViewMulti();
+    bool negate_pending(const Glib::RefPtr<Gtk::TreeModel>& model,
+                        const Gtk::TreeModel::Path& path,
+                        bool path_currently_selected) {
+        return !pending;
+    }
 };

 class Actions {

相关内容