Activating a button: Visual effect
- From: Jeans <jeans ace ulyssis org>
- To: gtk-app-devel-list gnome org
- Subject: Activating a button: Visual effect
- Date: Wed, 1 Nov 2000 08:50:17 +0100 (CET)
To create the visual effect, we use the following code in
SNAC <http://snac.seul.org/>
We got this code from John Sullivan on this list.
Use: nautilus_gtk_button_auto_click(GTK_BUTTON(button));
Hope this helps,
Jeans
/*
* This number should be large enough to be visually noticeable,
* but small enough to not allow the user to perform other actions.
* Author: John Sullivan <sullivan eazel com>
* From: Nautilus
*/
#define BUTTON_AUTO_HIGHLIGHT_MILLISECONDS 100
static gboolean
finish_button_activation (gpointer data)
{
GtkButton *button;
button = GTK_BUTTON (data);
if (!button->in_button) {
gtk_button_clicked (button);
}
gtk_button_released (button);
return FALSE;
}
/**
* nautilus_gtk_button_auto_click:
*
* Programatically activate a button as if the user had clicked on it,
* including briefly drawing the button's pushed-in state.
* @button: Any GtkButton.
* Author: John Sullivan <sullivan eazel com>
* From: Nautilus
**/
void
nautilus_gtk_button_auto_click (GtkButton *button)
{
g_return_if_fail (GTK_IS_BUTTON (button));
if (!GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (button))) {
return;
}
button->in_button = TRUE;
gtk_button_pressed (button);
button->in_button = FALSE;
/* FIXME bugzilla.eazel.com 2562:
* Nothing is preventing other events from occuring between
* now and when this timeout function fires, which means in
* theory the user could click on a different row or otherwise
* get in between the double-click and the button activation.
* In practice the timeout is short enough that this probably
* isn't a problem.
*/
g_timeout_add (BUTTON_AUTO_HIGHLIGHT_MILLISECONDS,
finish_button_activation, button);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]