Re: deactivate "enter" signal on GtkButton
- From: Andrew Potter <agpotter gmail com>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: deactivate "enter" signal on GtkButton
- Date: Thu, 7 Nov 2013 21:32:31 -0800
On Thu, Nov 7, 2013 at 7:06 PM, Mahesh Chaudhari
<mahesh chaudhari ymail com> wrote:
On Thursday, 7 November 2013 10:46 AM, Andrew Potter <agpotter gmail com>
wrote:
On Thu, Nov 7, 2013 at 4:10 AM, Mahesh Chaudhari
<mahesh chaudhari ymail com> wrote:
Also (unsuccessfully) tried :
void enter_button1(GtkWidget *widget, gpointer data)
{
GtkStyle *style;
style = gtk_widget_get_style(button1);
style->bg[GTK_STATE_PRELIGHT] = style->bg[GTK_STATE_NORMAL];
gtk_widget_set_style(button1, style);
}
This may not have worked because the theme style may be being applied
after you call this function.
Actually the reason is may be that your theme is not setting the
background color, but is instead setting a _background image_.
What I found is that on my installation, a background image was being
set for the default button image, the image being a gradient from top
to bottom of a darker shade of gray. On hover, this gradient was not
drawn.
The example program below prevents my global theme from setting any
background image by default by overwriting it with a completely
transparent image of my own. This may or may not be what you want.
The question becomes, "How do I set a theme selector to use a
different, possibly defined elsewhere, selector?" e.g. set
GtkButton:hover to look the same as the standard GtkButton, whatever
it is.
I don't know.
#include <gtk/gtk.h>
const gchar my_style[] = "GtkButton:hover,\
GtkButton:prelight, \
GtkButton \
{ \
background-image: -gtk-gradient(linear, center top, center bottom,
from(rgba(0,0,255,0)), to (rgba(0,0,255,0))); \
}";
void on_realize(GtkWidget *widget, gpointer user_data) {
GError *error = NULL;
GdkScreen *screen = gtk_widget_get_screen(widget);
GtkCssProvider *provider = gtk_css_provider_get_default();
gtk_css_provider_load_from_data(provider, my_style,
G_N_ELEMENTS(my_style), &error);
if (error) {
fprintf(stderr, "Error loading CSS Theme: %s\n", error->message);
g_error_free(error);
} else {
gtk_style_context_add_provider_for_screen(screen,
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
}
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *grid = gtk_grid_new();
GtkWidget *button = gtk_button_new_with_label("Button!");
gtk_container_add(GTK_CONTAINER(grid), gtk_label_new("Label 1"));
gtk_container_add(GTK_CONTAINER(grid), button);
gtk_container_add(GTK_CONTAINER(grid), gtk_label_new("Label 2"));
gtk_container_add(GTK_CONTAINER(window), grid);
g_signal_connect(window, "realize", G_CALLBACK(on_realize), NULL);
g_signal_connect(window, "hide", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]