tags:

views:

76

answers:

1
+1  Q: 

Remove button box

I'm writing an application in C and I've a GtkLinkButton that contains a GtkStockItem. How can I remove the button box that appears when mouse pointer is on and when I click it?



EDIT

Thanks very much, but it doesn't work. This is the output:

"Gtk-WARNING **: filed to set text from markup due to error parsing markup: Unknow tag 'a' on line 1 char 38

GLib-GObject-WARNING **: gsignal.c:2267: sigal activate-link' is invalid for istance0x8081860'

Gtk-WARNING **: filed to set text from markup due to error parsing markup: Unknow tag 'a' on line 1 char 38"

I study GTK libraries since few time, but I think that you can't use all html tags that you want in gtk_label_set_markup() function (tag 'a' is one). I understand that you can only use Pango text markup language (http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html), so you can't use tag 'a' or not directly.

+1  A: 
gtk_button_set_relief(GTK_BUTTON(link_button), GTK_RELIEF_NONE);

Addenum:

Yes, you are right! There is no way to let a GtkButton behaves in that way (and to my eyes, GTK_RELIEF_HALF and GTK_RELIEF_NORMAL looks the same).

You could use a GtkLabel instead. In C, that would be something like:

label = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(label), "<a href='http://www.gtk.org'&gt;GTK+ home</a>");

Example:

I really hate to do your homeworks... Anyway I'm feeling great, so here it is a fully working example:

/*
gcc `pkg-config --cflags gtk+-2.0` link.c \
    -o link `pkg-config --libs gtk+-2.0`
*/
#include <gtk/gtk.h>

static gboolean
my_dialog(GtkWindow *top_level)
{
    GtkWidget *dialog = gtk_message_dialog_new(top_level,
                                               GTK_DIALOG_MODAL,
                                               GTK_MESSAGE_INFO,
                                               GTK_BUTTONS_CLOSE,
                                               "This is a test message");

    gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_destroy(dialog);

    return TRUE;
}

int
main(int argc, char *argv[])
{
    GtkWidget *window, *label;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label),
                         "<a href='http://www.gtk.org'&gt;GTK+ web site</a>");
    g_signal_connect_swapped(label, "activate-link",
                             G_CALLBACK(my_dialog), window);
    gtk_container_add(GTK_CONTAINER(window), label);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
giassai
I've already used it, but doesn't work.
stdio
I have to open a GtkDialog window with the click. If I use GtkLabel, how can I do this?
stdio
With a bit of initiative: http://library.gnome.org/devel/gtk/stable/GtkLabel.html#GtkLabel-activate-link
giassai
I know this, but how can I do what I want? I've a GtkLabel (that must be clickable); when I click it, must appear a GtkDialog.Can you write example code? thanks
stdio
Thanks, but see my edit.
stdio
"activate-link" and <a> in markup are available since GTK+ 2.18. The example provided runs flawlessy on GTK+ 2.20.1
giassai
Oh,for this reason also my code didn't work! I verified and I've 2.14.7 version. I do the upgrade.
stdio
Ok, now no errors, but when I click the label the GtkDialog doesn't appear and finally, I'm the starting point: when mouse pointer is on the label, a "label box" appear. So, I must find a way to remove button box and use them (that are manageable more easily and quickly).
stdio