/** * gtk_toggle_tool_button_set_active: * @button: a #GtkToggleToolButton * @is_active: whether @button should be active * * Sets the status of the toggle tool button. Set to %TRUE if you * want the GtkToggleButton to be 'pressed in', and %FALSE to raise it. * This action causes the toggled signal to be emitted. * * Since: 2.4 **/ void gtk_toggle_tool_button_set_active (GtkToggleToolButton *button, gboolean is_active) { g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button)); is_active = is_active != FALSE; if (button->priv->active != is_active) gtk_button_clicked (GTK_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)))); }
static void gtk_toggle_tool_button_init (GtkToggleToolButton *button) { GtkToolButton *tool_button = GTK_TOOL_BUTTON (button); GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)); button->priv = gtk_toggle_tool_button_get_instance_private (button); /* If the real button is a radio button, it may have been * active at the time it was created. */ button->priv->active = gtk_toggle_button_get_active (toggle_button); g_signal_connect_object (toggle_button, "toggled", G_CALLBACK (button_toggled), button, 0); }
/* There are two activatable widgets, a toggle button and a menu item. * * If a widget is activated and the state of the tool button is the same as * the new state of the activated widget, then the other widget was the one * that was activated by the user and updated the tool button's state. * * If the state of the tool button is not the same as the new state of the * activated widget, then the activation was activated by the user, and the * widget needs to make sure the tool button is updated before the other * widget is activated. This will make sure the other widget a tool button * in a state that matches its own new state. */ static void menu_item_activated (GtkWidget *menu_item, GtkToggleToolButton *toggle_tool_button) { GtkToolButton *tool_button = GTK_TOOL_BUTTON (toggle_tool_button); gboolean menu_active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item)); if (toggle_tool_button->priv->active != menu_active) { toggle_tool_button->priv->active = menu_active; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)), toggle_tool_button->priv->active); g_object_notify (G_OBJECT (toggle_tool_button), "active"); g_signal_emit (toggle_tool_button, toggle_signals[TOGGLED], 0); } }
static void gtk_radio_tool_button_init (GtkRadioToolButton *button) { GtkToolButton *tool_button = GTK_TOOL_BUTTON (button); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)), FALSE); }
static GtkRadioButton * get_radio_button (GtkRadioToolButton *button) { return GTK_RADIO_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button))); }
static void gtk_radio_tool_button_init (GtkRadioToolButton *button) { GtkToolButton *tool_button = GTK_TOOL_BUTTON (button); gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (_gtk_tool_button_get_button (tool_button)), FALSE); }