0

我正在尝试将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);
4

2 回答 2

1

看起来您缺少提供定义的包含MATE_PANEL_APPLET_OUT_PROCESS_FACTORY

于 2012-12-23T22:58:40.283 回答
1

原来我只是在使用旧版本的 libmatepanel 库。我使用的是 2.0,而当前版本是 3.0。出于某种原因,我的系统上都有

于 2012-12-24T13:00:34.697 回答