You are not logged in.

#1 2009-03-11 21:26:09

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

passing an argument from an incompatible pointer type [solved]

Hey, Im trying to install the pidgin fonomobutton plugin, but everytime I try to compile it, I get this error:

fonomobutton.c:112: warning: passing argument 2 of 'gtk_icon_theme_choose_icon' from incompatible pointer type

Here is the c code, does anyone know if theres an issue with the code or if Im just compiling this wrong?

/*
 * Fonomo video chat launcher 
 * Copyright (C) 2008 Eric Windisch
 *
 * based on code by...
 * Copyright (C) 2008 Etan Reisner <deryni@pidgin.im>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
 */

#define PURPLE_PLUGINS

#include <glib.h>


#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
#    define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
#    define G_GNUC_NULL_TERMINATED
# endif
#endif

#include "notify.h"
#include "plugin.h"
#include "version.h"

#include "pidgin.h"

#include "gtkconv.h"
#include "gtkplugin.h"

#include "conversation.h"
#include "gtkconvwin.h"

#include "gtkimhtml.h"

#ifdef G_OS_WIN32
#include "win32/win32dep.h"
#endif

static void
send_button_cb(GtkButton *button, PidginConversation *gtkconv)
{
    guint32 randnum;
    gchar *url;
    gchar *url2;
    gchar *joinstr;

    randnum = g_random_int();

    url = g_strdup_printf ("http://www.fonomo.com/chat.html?n=1&key=%X", randnum);
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, url);

    url2 = g_strdup_printf ("http://www.fonomo.com/chat.html?key=%X", randnum);
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, url2);

    purple_notify_uri(NULL, url);
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "url launched");

    joinstr = g_strdup_printf("I'm inviting you to a video chat. <a href=\"%s\">Click here to join</a>.", url2);

    gtk_imhtml_append_text(GTK_IMHTML(gtkconv->entry), joinstr, FALSE);
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "imhtml display fonomo\n");

    g_signal_emit_by_name(gtkconv->entry, "message_send");
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "message sent\n");

    g_free(url);
    g_free(url2);
    g_free(joinstr);
}

static void
create_fonomo_button_pidgin (PidginConversation *conv)
{
    GtkWidget *button, *image, *sep;
    GtkIconInfo *icoinfo;
    gchar *iconames[]={"camera-web", "camera-fonomo"};

    button = gtk_button_new();
    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    g_signal_connect(G_OBJECT(button), "clicked",
    G_CALLBACK(send_button_cb), conv);

#ifdef DATADIR
    /*
     * I prefer that we do this themable, but if we are building directly
     * against the pidgin source tree, then we will use the DATADIR
     * since that is how pidgin itself uses its icons.  This also
     * works reliably under MS Windows.
     */
    image = gtk_image_new_from_file(g_build_filename(DATADIR,"pixmaps","hicolor","22x22","devices","camera-fonomo.png",NULL));
#else
    /* We test if the current theme has an existing icon,
     * or if hicolor has an icon, and if not, 
     * we fallback to our own ugly icon.
     */
    icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames,22,0);
    image = gtk_image_new_from_file(gtk_icon_info_get_filename(icoinfo));
#endif 

    gtk_container_add((GtkContainer *)button, image);

    sep = gtk_vseparator_new();

    gtk_widget_show(sep);
    gtk_widget_show(image);
    gtk_widget_show(button);

    gtk_box_pack_start(GTK_BOX(conv->toolbar), sep, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(conv->toolbar), button, FALSE, FALSE, 0);

    g_object_set_data(G_OBJECT(conv->toolbar), "fonomo_separator", sep);
    g_object_set_data(G_OBJECT(conv->toolbar), "fonomo_button", button);
}

static void
remove_fonomo_button_pidgin(PidginConversation *gtkconv)
{
    GtkWidget *send_button = NULL, *separator = NULL;

    send_button = g_object_get_data(G_OBJECT(gtkconv->toolbar), "fonomo_button");
    if (send_button != NULL) {
        gtk_container_remove(GTK_CONTAINER(gtkconv->toolbar), send_button);
        g_signal_handlers_disconnect_by_func(G_OBJECT(send_button),
                G_CALLBACK(send_button_cb), gtkconv);
        gtk_widget_destroy(send_button);
    }

    separator = g_object_get_data(G_OBJECT(gtkconv->toolbar), "fonomo_separator");
    if (send_button != NULL) {
        gtk_container_remove(GTK_CONTAINER(gtkconv->toolbar), separator);
        gtk_widget_destroy(separator);
    }
}

static gboolean
plugin_load(PurplePlugin *plugin)
{
    GList *convs = purple_get_conversations();
    void *gtk_conv_handle = pidgin_conversations_get_handle();

    purple_signal_connect(gtk_conv_handle, "conversation-displayed",
    plugin, PURPLE_CALLBACK(create_fonomo_button_pidgin), NULL);

    while (convs) {
        PurpleConversation *conv = (PurpleConversation *)convs->data;

        /* Setup Send button */
        if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
            create_fonomo_button_pidgin(PIDGIN_CONVERSATION(conv));
        }

        convs = convs->next;
    }

    return TRUE;
}

static gboolean
plugin_unload(PurplePlugin *plugin)
{
    GList *convs = purple_get_conversations();

    while (convs) {
        PurpleConversation *conv = (PurpleConversation *)convs->data;

        /* Remove Send button */
        if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
            remove_fonomo_button_pidgin(PIDGIN_CONVERSATION(conv));
        }

        convs = convs->next;
    }

    return TRUE;
}

static PurplePluginInfo info =
{
    PURPLE_PLUGIN_MAGIC,
    PURPLE_MAJOR_VERSION,                           /**< major version */
    PURPLE_MINOR_VERSION,                           /**< minor version */
    PURPLE_PLUGIN_STANDARD,                         /**< type */
    PIDGIN_PLUGIN_TYPE,                             /**< ui_requirement */
    0,                                              /**< flags */
    NULL,                                           /**< dependencies */
    PURPLE_PRIORITY_DEFAULT,                        /**< priority */
    "gtk-ewindisch-fonomobutton",                                /**< id */
    "Fonomo Video Chat",                              /**< name */
    "0.1.5",                                /**< version */
    "Spawns Fonomo chat",         /**< summary */
    "Adds a video-chat button to the "
       "the conversation window.",         /**< description */
    "Eric Windisch <eric@fonomo.com>",              /**< author */
    "http://www.fonomo.com/",                                 /**< homepage */
    plugin_load,                                    /**< load */
    plugin_unload,                                  /**< unload */
    NULL,                                           /**< destroy */
    NULL,                                           /**< ui_info */
    NULL,                                           /**< extra_info */
    NULL,                                           /**< prefs_info */
    NULL,                                           /**< actions */

    /* padding */
    NULL,
    NULL,
    NULL,
    NULL
};

static void
init_plugin(PurplePlugin *plugin)
{
}

PURPLE_INIT_PLUGIN(fonomobutton, init_plugin, info)

Last edited by wankel (2009-03-12 23:43:54)

Offline

#2 2009-03-11 23:02:59

r.b
Member
From: Winnipeg, MB
Registered: 2009-03-11
Posts: 12

Re: passing an argument from an incompatible pointer type [solved]

I'm not sure if this is the problem, but shouldn't iconames be NULL-terminated?


:wq

Offline

#3 2009-03-11 23:29:04

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

r.b wrote:

I'm not sure if this is the problem, but shouldn't iconames be NULL-terminated?

I didnt write the code so I know very little about programming, could you explain this further? Thanks smile

Offline

#4 2009-03-11 23:36:35

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: passing an argument from an incompatible pointer type [solved]

it would be more usefull if you paste the hole output. that is just a warning


Give what you have. To someone, it may be better than you dare to think.

Offline

#5 2009-03-11 23:43:17

r.b
Member
From: Winnipeg, MB
Registered: 2009-03-11
Posts: 12

Re: passing an argument from an incompatible pointer type [solved]

I just realized that there's a package for this in AUR. You can find it at http://aur.archlinux.org/packages.php?ID=24351


:wq

Offline

#6 2009-03-12 00:13:39

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: passing an argument from an incompatible pointer type [solved]

    icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames,22,0);

I'm not too sure myself but maybe this should read:

    icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames[0],22,0);

Offline

#7 2009-03-12 02:02:10

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

r.b wrote:

I just realized that there's a package for this in AUR. You can find it at http://aur.archlinux.org/packages.php?ID=24351

I tried the aur package first, it gives me the same error and doesnt install.

Offline

#8 2009-03-12 02:02:46

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

HashBox wrote:
    icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames,22,0);

I'm not too sure myself but maybe this should read:

    icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames[0],22,0);

Thanks HashBox, let me try this out and Ill send the full output if it doesnt work.

Offline

#9 2009-03-12 02:06:19

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

[atayh@cerberus pidgin-fonomobutton-0.1.5]$ make all install
gcc `pkg-config pidgin --cflags --libs` --shared -Wall -O2 fonomobutton.c -o fonomobutton.so
fonomobutton.c: In function 'create_fonomo_button_pidgin':
fonomobutton.c:113: warning: passing argument 2 of 'gtk_icon_theme_choose_icon' from incompatible pointer type
/usr/bin/ld: /tmp/cc46IrBc.o: relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/cc46IrBc.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [all] Error 1

This is the error I get when I try to compile it myself or install from the AUR. Not sure what the issue is?

Offline

#10 2009-03-12 16:18:21

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: passing an argument from an incompatible pointer type [solved]

add -fPIC in Makefile

gcc `pkg-config pidgin --cflags --libs` --shared -fPIC -Wall -O2 fonomobutton.c -o fonomobutton.so


Give what you have. To someone, it may be better than you dare to think.

Offline

#11 2009-03-12 17:01:08

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

wonder wrote:

add -fPIC in Makefile

gcc `pkg-config pidgin --cflags --libs` --shared -fPIC -Wall -O2 fonomobutton.c -o fonomobutton.so

It still gave me the first warning about the incompatible pointer type, but it did compile into fonomobutton.so and everything works fine. Thanks everyone smile

Offline

#12 2009-03-12 22:14:52

Killa B
Member
From: United States
Registered: 2008-10-28
Posts: 42
Website

Re: passing an argument from an incompatible pointer type [solved]

Changing

icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames,22,0);

to:

icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),(const gchar**)iconames,22,0);

might get rid of the warning. It probably doesn't really matter (though if I were the developer I'd make sure GCC didn't give any warnings. My 2¢).

Last edited by Killa B (2009-03-12 22:20:42)

Offline

#13 2009-03-12 23:43:11

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: passing an argument from an incompatible pointer type [solved]

Killa B wrote:

Changing

icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),iconames,22,0);

to:

icoinfo=gtk_icon_theme_choose_icon(
    gtk_icon_theme_get_default(),(const gchar**)iconames,22,0);

might get rid of the warning. It probably doesn't really matter (though if I were the developer I'd make sure GCC didn't give any warnings. My 2¢).

Adding -fPIC to makefile and making this change in the c code solved everything, it now compiles without warning. Thanks again everyone smile

Offline

Board footer

Powered by FluxBB