How to make the toolbar button flashing
- From: "Miroslav Rajcic" <rajcic sokrates hr>
- To: <gtk-app-devel-list gnome org>
- Subject: How to make the toolbar button flashing
- Date: Tue, 1 Mar 2011 09:20:06 +0100
I am trying to make the "Pause" button flash (or show any similar behaviour
similar to that) when the pause state is active.
So far I tried many things, but none of these seem to work:
- changing the button background color
- changing the button stock icon
- changing the button relief style
Relevant code is following:
//start timer to alternate the button state
nBlinkButtonTimerID = g_timeout_add (900, flash_pause_button_timer, NULL);
gboolean flash_pause_button_timer(gpointer data)
{
static bool bFlipFlop = false;
bFlipFlop = !bFlipFlop;
//get pointers to the relevant buttons
GtkToolbar *toolbar2 = (GtkToolbar *)lookup_widget(window1, "toolbar2");
GtkWidget *tool_pause = (GtkWidget *)gtk_toolbar_get_nth_item(toolbar2, 2);
GList *children1 = gtk_container_get_children(GTK_CONTAINER(tool_pause));
GtkButton *button = (GtkButton *)g_list_nth_data (children1, 0);
g_list_free(children1);
GtkWidget *tool_stop = (GtkWidget *)gtk_toolbar_get_nth_item(toolbar2, 1);
//create two alternating colors (standard bkg and black bkg)
GtkStyle* style = gtk_rc_get_style(tool_stop);
GdkColor rgbStart = style->bg[GTK_STATE_NORMAL];
GdkColor rgbEnd = { 0, 0, 0, 0 };
//modify color
gtk_widget_modify_bg (GTK_WIDGET(button), GTK_STATE_NORMAL, (bFlipFlop)?
&rgbEnd : &rgbStart);
gtk_widget_modify_bg (GTK_WIDGET(button), GTK_STATE_ACTIVE, (bFlipFlop)?
&rgbEnd : &rgbStart);
gtk_widget_modify_base (GTK_WIDGET(button), GTK_STATE_NORMAL, (bFlipFlop)?
&rgbEnd : &rgbStart);
gtk_widget_modify_base (GTK_WIDGET(button), GTK_STATE_ACTIVE, (bFlipFlop)?
&rgbEnd : &rgbStart);
gtk_widget_queue_draw (GTK_WIDGET(button));
#if GTK_CHECK_VERSION(2,18,0)
gdk_window_process_updates (gtk_widget_get_window(GTK_WIDGET(button)),
TRUE);
#else
gdk_window_process_updates (GTK_WIDGET(button)->window, TRUE);
#endif
/*
GtkWidget *w1 =
gtk_tool_button_get_icon_widget(GTK_TOOL_BUTTON(tool_pause));
gtk_widget_modify_bg (w1, GTK_STATE_NORMAL, (bFlipFlop)? &rgbEnd :
&rgbStart);
gtk_widget_modify_bg (w1, GTK_STATE_ACTIVE, (bFlipFlop)? &rgbEnd :
&rgbStart);
gtk_widget_modify_base (w1, GTK_STATE_NORMAL, (bFlipFlop)? &rgbEnd :
&rgbStart);
gtk_widget_modify_base (w1, GTK_STATE_ACTIVE, (bFlipFlop)? &rgbEnd :
&rgbStart);
*/
//modify relief style
gtk_button_set_relief(button, (bFlipFlop)?
GTK_RELIEF_NORMAL:GTK_RELIEF_NONE);
//modify stock icon
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(tool_pause), (bFlipFlop)?
GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_RECORD);
gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM(tool_pause));
return TRUE;
}
Why doesn't any of these work ? Any tips ?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]