Remove GtkButton's image padding (inner-border)?
In C/GTK, is there a way to remove the inner-border for a GtkButton that has an image using gtk_button_set_image?
gtk_button_set_relief (GTK_BUTTON (but开发者_如何转开发ton), GTK_RELIEF_NONE);
sort of did the job but a mouseover showed that it merely hides it.
I would prefer to do this without using an RC style, but if there's no other way, an example on how to use the RC styles would be appreciated.
Basically, I need a way of not having the "glow" effect when the mouse hovers a GtkButton.
Note: Also, this is the latest stable version of gtk+ 2.0
You can use GtkStyle to disable the "glow" button.
Example :
#include <gtk/gtk.h>
static void destroy (GtkWidget *widget, gpointer data){
gtk_main_quit();
}
int main( int argc, char *argv[]){
GtkWidget *window;
GtkWidget *button;
GtkStyle *style;
gtk_init(&argc, &argv);
/* window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW (window), "my Program");
gtk_widget_set_usize(window,200,150);
gtk_window_set_position(GTK_WINDOW (window),GTK_WIN_POS_CENTER);
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC(destroy),NULL);
/* Create a new button (NO GLOW) */
button = gtk_button_new_with_label ("Exit");
/*-------------------------------------------------------------*/
style = gtk_widget_get_style(button);
style->bg[GTK_STATE_PRELIGHT] = style->bg[GTK_STATE_NORMAL];
gtk_widget_set_style(button, style);
/*-------------------------------------------------------------*/
gtk_container_add (GTK_CONTAINER (window), button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (destroy), NULL);
gtk_widget_show(button);
gtk_widget_show(window);
gtk_main();
return 0;
}
精彩评论