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 istance
0x8081860'
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.
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'>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'>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;
}
精彩评论