我正在尝试将https://github.com/alexkay/xmonad-log-applet从 GNOME2 移植到 MATE,到目前为止,我已经完成了配置等,我正在尝试构建。你可以在这里找到我的修改:https ://github.com/geniass/xmonad-log-applet 。当我运行时make
,它开始构建,但在最后一行它给出了这些错误:
main.c:92:39: error: expected declaration specifiers or ‘...’ before string constant
main.c:92:65: error: expected declaration specifiers or ‘...’ before ‘(’ token
main.c:92:84: error: expected declaration specifiers or ‘...’ before string constant
main.c:92:103: error: expected declaration specifiers or ‘...’ before ‘xmonad_log_applet_factory’
main.c:92:130: error: expected declaration specifiers or ‘...’ before ‘(’ token
我在 stackoverflow 上看到了很多类似的问题,但它们主要是关于省略花括号或方法原型返回类型。我在这里看不到任何东西,但也许我只是错过了一个?除了这种可能性,我完全不知道可能出了什么问题。这些错误对我来说完全没有意义
为了清楚起见,这是删除了 ifdef 的 main.c(给出了相同的错误):
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <mate-panel-applet.h>
static void signal_handler(DBusGProxy *obj, const char *msg, GtkWidget *widget)
{
gtk_label_set_markup(GTK_LABEL(widget), msg);
}
static void set_up_dbus_transfer(GtkWidget *buf)
{
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error= NULL;
connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if(connection == NULL) {
g_printerr("Failed to open connection: %s\n", error->message);
g_error_free(error);
exit(1);
}
proxy = dbus_g_proxy_new_for_name(
connection, "org.xmonad.Log", "/org/xmonad/Log", "org.xmonad.Log");
error = NULL;
dbus_g_proxy_add_signal(proxy, "Update", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(
proxy, "Update", (GCallback)signal_handler, buf, NULL);
}
static gboolean xmonad_log_applet_fill(MatePanelApplet *applet)
{
mate_panel_applet_set_flags(
applet,
MATE_PANEL_APPLET_EXPAND_MAJOR |
MATE_PANEL_APPLET_EXPAND_MINOR |
MATE_PANEL_APPLET_HAS_HANDLE);
mate_panel_applet_set_background_widget(applet, GTK_WIDGET(applet));
GtkWidget *label = gtk_label_new("Waiting for Xmonad...");
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
set_up_dbus_transfer(label);
gtk_container_add(GTK_CONTAINER(applet), label);
gtk_widget_show_all(GTK_WIDGET(applet));
return TRUE;
}
static gboolean xmonad_log_applet_factory(
MatePanelApplet *applet, const gchar *iid, gpointer data)
{
gboolean retval = FALSE;
if(!strcmp(iid, "XmonadLogApplet"))
retval = xmonad_log_applet_fill(applet);
if(retval == FALSE) {
printf("Wrong applet!\n");
exit(-1);
}
return retval;
}
MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("XmonadLogAppletFactory", PANEL_TYPE_APPLET, "XmonadLogApplet", xmonad_log_applet_factory, NULL);