forked from AuroraMiddleware/gtk
Merge branch 'actionable-fixes' into 'master'
tests: Fix check vs toggle button confusion Closes #4022 See merge request GNOME/gtk!3656
This commit is contained in:
commit
17f1bb1632
@ -1015,6 +1015,14 @@ gtk_button_get_gesture (GtkButton *button)
|
|||||||
return priv->gesture;
|
return priv->gesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkActionHelper *
|
||||||
|
gtk_button_get_action_helper (GtkButton *button)
|
||||||
|
{
|
||||||
|
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
|
||||||
|
|
||||||
|
return priv->action_helper;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_button_set_child: (attributes org.gtk.Method.set_property=child)
|
* gtk_button_set_child: (attributes org.gtk.Method.set_property=child)
|
||||||
* @button: a `GtkButton`
|
* @button: a `GtkButton`
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
#include "gtkbutton.h"
|
#include "gtkbutton.h"
|
||||||
|
|
||||||
#include "gtkgesture.h"
|
#include "gtkgesture.h"
|
||||||
|
#include "gtkactionhelperprivate.h"
|
||||||
|
|
||||||
GtkGesture * gtk_button_get_gesture (GtkButton *button);
|
GtkGesture * gtk_button_get_gesture (GtkButton *button);
|
||||||
|
GtkActionHelper * gtk_button_get_action_helper (GtkButton *button);
|
||||||
|
|
||||||
#endif /* __GTK_BUTTON_PRIVATE_H__ */
|
#endif /* __GTK_BUTTON_PRIVATE_H__ */
|
||||||
|
@ -325,10 +325,10 @@ click_released_cb (GtkGestureClick *gesture,
|
|||||||
|
|
||||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||||
|
|
||||||
gtk_check_button_set_active (self, !priv->active);
|
|
||||||
|
|
||||||
if (priv->action_helper)
|
if (priv->action_helper)
|
||||||
gtk_action_helper_activate (priv->action_helper);
|
gtk_action_helper_activate (priv->action_helper);
|
||||||
|
else
|
||||||
|
gtk_check_button_set_active (self, !priv->active);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -202,6 +202,9 @@ gtk_toggle_button_clicked (GtkButton *button)
|
|||||||
if (priv->active && (priv->group_prev || priv->group_next))
|
if (priv->active && (priv->group_prev || priv->group_next))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (gtk_button_get_action_helper (button))
|
||||||
|
return;
|
||||||
|
|
||||||
gtk_toggle_button_set_active (toggle_button, !priv->active);
|
gtk_toggle_button_set_active (toggle_button, !priv->active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,13 @@ toggle_menu_item (GSimpleAction *action,
|
|||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GVariant *state = g_action_get_state (G_ACTION (action));
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (label), "Text set from toggle menu item");
|
gtk_label_set_label (GTK_LABEL (label), "Text set from toggle menu item");
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, g_variant_new_boolean (!g_variant_get_boolean (state)));
|
||||||
|
|
||||||
|
g_variant_unref (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -39,15 +44,16 @@ submenu_item (GSimpleAction *action,
|
|||||||
static void
|
static void
|
||||||
radio (GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
radio (GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
GVariant *new_state = g_variant_new_string (g_variant_get_string (parameter, NULL));
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
str = g_strdup_printf ("From Radio menu item %s",
|
str = g_strdup_printf ("From Radio menu item %s",
|
||||||
g_variant_get_string (new_state, NULL));
|
g_variant_get_string (parameter, NULL));
|
||||||
|
|
||||||
gtk_label_set_label (GTK_LABEL (label), str);
|
gtk_label_set_label (GTK_LABEL (label), str);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +63,7 @@ static const GActionEntry win_actions[] = {
|
|||||||
{ "normal-menu-item", normal_menu_item, NULL, NULL, NULL },
|
{ "normal-menu-item", normal_menu_item, NULL, NULL, NULL },
|
||||||
{ "toggle-menu-item", toggle_menu_item, NULL, "true", NULL },
|
{ "toggle-menu-item", toggle_menu_item, NULL, "true", NULL },
|
||||||
{ "submenu-item", submenu_item, NULL, NULL, NULL },
|
{ "submenu-item", submenu_item, NULL, NULL, NULL },
|
||||||
{ "radio", radio, "s", "1", NULL },
|
{ "radio", radio, "s", "'1'", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -112,6 +118,7 @@ int main (int argc, char **argv)
|
|||||||
GtkWidget *button1 = gtk_button_new_with_label ("Change Label Text");
|
GtkWidget *button1 = gtk_button_new_with_label ("Change Label Text");
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
GSimpleActionGroup *action_group;
|
GSimpleActionGroup *action_group;
|
||||||
|
GtkWidget *box1;
|
||||||
|
|
||||||
|
|
||||||
action_group = g_simple_action_group_new ();
|
action_group = g_simple_action_group_new ();
|
||||||
@ -142,6 +149,50 @@ int main (int argc, char **argv)
|
|||||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (button1), "win.change-label-button");
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (button1), "win.change-label-button");
|
||||||
gtk_box_append (GTK_BOX (box), button1);
|
gtk_box_append (GTK_BOX (box), button1);
|
||||||
|
|
||||||
|
box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||||
|
|
||||||
|
button1 = gtk_toggle_button_new_with_label ("Toggle");
|
||||||
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (button1), "win.toggle-menu-item");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
button1 = gtk_check_button_new_with_label ("Check");
|
||||||
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (button1), "win.toggle-menu-item");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
gtk_box_append (GTK_BOX (box), box1);
|
||||||
|
|
||||||
|
box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||||
|
|
||||||
|
button1 = gtk_toggle_button_new_with_label ("Radio 1");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::1");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
button1 = gtk_toggle_button_new_with_label ("Radio 2");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::2");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
button1 = gtk_toggle_button_new_with_label ("Radio 3");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::3");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
gtk_box_append (GTK_BOX (box), box1);
|
||||||
|
|
||||||
|
box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||||
|
|
||||||
|
button1 = gtk_check_button_new_with_label ("Radio 1");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::1");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
button1 = gtk_check_button_new_with_label ("Radio 2");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::2");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
button1 = gtk_check_button_new_with_label ("Radio 3");
|
||||||
|
gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button1), "win.radio::3");
|
||||||
|
gtk_box_append (GTK_BOX (box1), button1);
|
||||||
|
|
||||||
|
gtk_box_append (GTK_BOX (box), box1);
|
||||||
|
|
||||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||||
|
|
||||||
gtk_widget_show (window);
|
gtk_widget_show (window);
|
||||||
|
@ -418,7 +418,7 @@ create_action_treeview (GActionGroup *group)
|
|||||||
/* Dynamic menu changes {{{1 */
|
/* Dynamic menu changes {{{1 */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toggle_sumerian (GtkToggleButton *button, gpointer data)
|
toggle_sumerian (GtkCheckButton *button, gpointer data)
|
||||||
{
|
{
|
||||||
GMenuModel *model;
|
GMenuModel *model;
|
||||||
gboolean adding;
|
gboolean adding;
|
||||||
@ -426,7 +426,7 @@ toggle_sumerian (GtkToggleButton *button, gpointer data)
|
|||||||
|
|
||||||
model = g_object_get_data (G_OBJECT (button), "model");
|
model = g_object_get_data (G_OBJECT (button), "model");
|
||||||
|
|
||||||
adding = gtk_toggle_button_get_active (button);
|
adding = gtk_check_button_get_active (button);
|
||||||
|
|
||||||
m = g_menu_model_get_item_link (model, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION);
|
m = g_menu_model_get_item_link (model, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION);
|
||||||
m = g_menu_model_get_item_link (m, g_menu_model_get_n_items (m) - 1, G_MENU_LINK_SUBMENU);
|
m = g_menu_model_get_item_link (m, g_menu_model_get_n_items (m) - 1, G_MENU_LINK_SUBMENU);
|
||||||
@ -467,7 +467,7 @@ action_list_remove (GtkTreeModel *store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toggle_italic (GtkToggleButton *button, gpointer data)
|
toggle_italic (GtkCheckButton *button, gpointer data)
|
||||||
{
|
{
|
||||||
GMenuModel *model;
|
GMenuModel *model;
|
||||||
GActionGroup *group;
|
GActionGroup *group;
|
||||||
@ -482,7 +482,7 @@ toggle_italic (GtkToggleButton *button, gpointer data)
|
|||||||
|
|
||||||
store = gtk_tree_view_get_model (tv);
|
store = gtk_tree_view_get_model (tv);
|
||||||
|
|
||||||
adding = gtk_toggle_button_get_active (button);
|
adding = gtk_check_button_get_active (button);
|
||||||
|
|
||||||
m = g_menu_model_get_item_link (model, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION);
|
m = g_menu_model_get_item_link (model, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION);
|
||||||
if (adding)
|
if (adding)
|
||||||
@ -503,7 +503,7 @@ toggle_italic (GtkToggleButton *button, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toggle_speed (GtkToggleButton *button, gpointer data)
|
toggle_speed (GtkCheckButton *button, gpointer data)
|
||||||
{
|
{
|
||||||
GMenuModel *model;
|
GMenuModel *model;
|
||||||
GActionGroup *group;
|
GActionGroup *group;
|
||||||
@ -519,7 +519,7 @@ toggle_speed (GtkToggleButton *button, gpointer data)
|
|||||||
|
|
||||||
store = gtk_tree_view_get_model (tv);
|
store = gtk_tree_view_get_model (tv);
|
||||||
|
|
||||||
adding = gtk_toggle_button_get_active (button);
|
adding = gtk_check_button_get_active (button);
|
||||||
|
|
||||||
m = g_menu_model_get_item_link (model, 1, G_MENU_LINK_SECTION);
|
m = g_menu_model_get_item_link (model, 1, G_MENU_LINK_SECTION);
|
||||||
if (adding)
|
if (adding)
|
||||||
|
Loading…
Reference in New Issue
Block a user