Commit af6e0ee2 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Use gtk_button_set_child throughout

Replace all uses of gtk_container_add on buttons
by gtk_button_set_child.
parent 04e4a02c
......@@ -37,7 +37,7 @@ color_swatch_new (const gchar *color)
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (area), 24);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (area), 24);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), draw_color, (gpointer) color, NULL);
gtk_container_add (GTK_CONTAINER (button), area);
gtk_button_set_child (GTK_BUTTON (button), area);
return button;
}
......
......@@ -36,16 +36,16 @@ do_headerbar (GtkWidget *do_widget)
icon = g_themed_icon_new ("mail-send-receive-symbolic");
image = gtk_image_new_from_gicon (icon);
g_object_unref (icon);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_add_css_class (box, "linked");
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_container_add (GTK_CONTAINER (box), button);
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-end-symbolic"));
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("pan-end-symbolic"));
gtk_container_add (GTK_CONTAINER (box), button);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), box);
......
......@@ -32,7 +32,7 @@ do_transparent (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (window), overlay);
button = gtk_button_new_with_label ("Don't click this button!");
label = gtk_bin_get_child (GTK_BIN (button));
label = gtk_button_get_child (GTK_BUTTON (button));
gtk_widget_set_margin_start (label, 50);
gtk_widget_set_margin_end (label, 50);
gtk_widget_set_margin_top (label, 50);
......@@ -45,7 +45,7 @@ do_transparent (GtkWidget *do_widget)
blur_overlay_add_overlay (BLUR_OVERLAY (overlay), button, 5.0);
button = gtk_button_new_with_label ("Maybe this one?");
label = gtk_bin_get_child (GTK_BIN (button));
label = gtk_button_get_child (GTK_BUTTON (button));
gtk_widget_set_margin_start (label, 50);
gtk_widget_set_margin_end (label, 50);
gtk_widget_set_margin_top (label, 50);
......
......@@ -1130,7 +1130,7 @@ create_headerbar (void)
bar = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), bar);
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("bookmark-new-symbolic"));
gtk_button_set_child (GTK_BUTTON (button), gtk_image_new_from_icon_name ("bookmark-new-symbolic"));
gtk_header_bar_pack_end (GTK_HEADER_BAR (bar), button);
return new_widget_info ("headerbar", window, ASIS);
......
......@@ -26,7 +26,7 @@
static void atk_action_interface_init (AtkActionIface *iface);
static void atk_image_interface_init (AtkImageIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkButtonAccessible, gtk_button_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
G_DEFINE_TYPE_WITH_CODE (GtkButtonAccessible, gtk_button_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
......@@ -60,7 +60,7 @@ get_image_from_button (GtkWidget *button)
{
GtkWidget *image;
image = gtk_bin_get_child (GTK_BIN (button));
image = gtk_button_get_child (GTK_BUTTON (button));
if (GTK_IS_IMAGE (image))
return image;
......@@ -99,7 +99,7 @@ get_label_from_button (GtkWidget *button)
{
GtkWidget *child;
child = gtk_bin_get_child (GTK_BIN (button));
child = gtk_button_get_child (GTK_BUTTON (button));
if (GTK_IS_CONTAINER (child))
child = find_label_child (GTK_CONTAINER (child));
......
......@@ -458,7 +458,7 @@ setup_search (GtkAppChooserDialog *self)
button = gtk_toggle_button_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
image = gtk_image_new_from_icon_name ("edit-find-symbolic");
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_widget_add_css_class (button, "image-button");
gtk_widget_remove_css_class (button, "text-button");
......
......@@ -279,7 +279,7 @@ gtk_color_button_init (GtkColorButton *button)
gtk_widget_set_size_request (button->swatch, rect.width, rect.height);
gtk_container_add (GTK_CONTAINER (button->button), button->swatch);
gtk_button_set_child (GTK_BUTTON (button->button), button->swatch);
button->title = g_strdup (_("Pick a Color")); /* default title */
......
......@@ -561,7 +561,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
gtk_container_add (GTK_CONTAINER (box), button->label);
gtk_widget_set_valign (icon, GTK_ALIGN_BASELINE);
gtk_container_add (GTK_CONTAINER (box), icon);
gtk_container_add (GTK_CONTAINER (button->button), box);
gtk_button_set_child (GTK_BUTTON (button->button), box);
gtk_widget_set_parent (button->button, GTK_WIDGET (button));
......
......@@ -558,7 +558,7 @@ gtk_font_button_init (GtkFontButton *font_button)
gtk_container_add (GTK_CONTAINER (font_button->font_size_box), font_button->size_label);
gtk_container_add (GTK_CONTAINER (box), font_button->font_size_box);
gtk_container_add (GTK_CONTAINER (font_button->button), box);
gtk_button_set_child (GTK_BUTTON (font_button->button), box);
gtk_widget_set_parent (font_button->button, GTK_WIDGET (font_button));
/* Initialize fields */
......
......@@ -140,7 +140,7 @@
* // Pressing Alt+H will activate this button
* GtkWidget *button = gtk_button_new ();
* GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
* gtk_container_add (GTK_CONTAINER (button), label);
* gtk_button_set_child (GTK_BUTTON (button), label);
* ]|
*
* There’s a convenience function to create buttons with a mnemonic label
......
......@@ -477,7 +477,7 @@ add_arrow (GtkMenuButton *self)
arrow = gtk_image_new ();
set_arrow_type (GTK_IMAGE (arrow), self->arrow_type);
gtk_container_add (GTK_CONTAINER (self->button), arrow);
gtk_button_set_child (GTK_BUTTON (self->button), arrow);
self->arrow_widget = arrow;
}
......@@ -697,8 +697,6 @@ void
gtk_menu_button_set_direction (GtkMenuButton *menu_button,
GtkArrowType direction)
{
GtkWidget *child;
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
if (menu_button->arrow_type == direction)
......@@ -708,11 +706,10 @@ gtk_menu_button_set_direction (GtkMenuButton *menu_button,
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_DIRECTION]);
/* Is it custom content? We don't change that */
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
if (menu_button->arrow_widget != child)
if (menu_button->arrow_widget != gtk_button_get_child (GTK_BUTTON (menu_button->button)))
return;
set_arrow_type (GTK_IMAGE (child), menu_button->arrow_type);
set_arrow_type (GTK_IMAGE (menu_button->arrow_widget), menu_button->arrow_type);
update_popover_direction (menu_button);
}
......@@ -878,17 +875,12 @@ void
gtk_menu_button_set_label (GtkMenuButton *menu_button,
const char *label)
{
GtkWidget *child;
GtkWidget *box;
GtkWidget *label_widget;
GtkWidget *image;
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
if (child)
gtk_container_remove (GTK_CONTAINER (menu_button->button), child);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label_widget = gtk_label_new (label);
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
......@@ -899,7 +891,7 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
image = gtk_image_new_from_icon_name ("pan-down-symbolic");
gtk_container_add (GTK_CONTAINER (box), label_widget);
gtk_container_add (GTK_CONTAINER (box), image);
gtk_container_add (GTK_CONTAINER (menu_button->button), box);
gtk_button_set_child (GTK_BUTTON (menu_button->button), box);
menu_button->label_widget = label_widget;
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_LABEL]);
......@@ -920,7 +912,7 @@ gtk_menu_button_get_label (GtkMenuButton *menu_button)
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
child = gtk_button_get_child (GTK_BUTTON (menu_button->button));
if (GTK_IS_BOX (child))
{
child = gtk_widget_get_first_child (child);
......@@ -998,13 +990,7 @@ void
gtk_menu_button_add_child (GtkMenuButton *menu_button,
GtkWidget *new_child)
{
GtkWidget *child;
child = gtk_bin_get_child (GTK_BIN (menu_button->button));
if (child)
gtk_container_remove (GTK_CONTAINER (menu_button->button), child);
gtk_container_add (GTK_CONTAINER (menu_button->button), new_child);
gtk_button_set_child (GTK_BUTTON (menu_button->button), new_child);
}
/**
......
......@@ -5547,7 +5547,7 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
menu_item = gtk_button_new ();
gtk_button_set_has_frame (GTK_BUTTON (menu_item), FALSE);
gtk_container_add (GTK_CONTAINER (menu_item), page->menu_label);
gtk_button_set_child (GTK_BUTTON (menu_item), page->menu_label);
gtk_container_add (GTK_CONTAINER (notebook->menu_box), menu_item);
g_signal_connect (menu_item, "clicked",
G_CALLBACK (gtk_notebook_menu_switch_page), page);
......@@ -5571,8 +5571,7 @@ static void
gtk_notebook_menu_label_unparent (GtkWidget *widget,
gpointer data)
{
gtk_widget_unparent (gtk_bin_get_child (GTK_BIN (widget)));
_gtk_bin_set_child (GTK_BIN (widget), NULL);
gtk_button_set_child (GTK_BUTTON (widget), NULL);
}
/* Public GtkNotebook Page Insert/Remove Methods :
......
......@@ -1061,7 +1061,7 @@ make_directory_button (GtkPathBar *path_bar,
button_data->file = g_object_ref (file);
button_data->file_is_hidden = file_is_hidden;
gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_button_set_child (GTK_BUTTON (button_data->button), child);
gtk_path_bar_update_button_appearance (path_bar, button_data, current_dir);
......
......@@ -739,7 +739,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
gtk_widget_add_css_class (w, "circular");
label = gtk_bin_get_child (GTK_BIN (w));
label = gtk_button_get_child (GTK_BUTTON (w));
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
}
......
......@@ -128,10 +128,6 @@ rebuild_child (GtkWidget *self,
{
GtkWidget *button_child;
button_child = gtk_bin_get_child (GTK_BIN (self));
if (button_child != NULL)
gtk_container_remove (GTK_CONTAINER (self), button_child);
button_child = NULL;
if (icon_name != NULL)
......@@ -157,7 +153,7 @@ rebuild_child (GtkWidget *self,
if (button_child)
{
gtk_widget_set_halign (GTK_WIDGET (button_child), GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (self), button_child);
gtk_button_set_child (GTK_BUTTON (self), button_child);
}
}
......
......@@ -897,7 +897,7 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
}
gtk_container_add (GTK_CONTAINER (priv->frame), child);
gtk_container_add (GTK_CONTAINER (priv->button), hbox);
gtk_button_set_child (GTK_BUTTON (priv->button), hbox);
}
static void
......@@ -917,7 +917,7 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
else
model = NULL;
hbox = gtk_bin_get_child (GTK_BIN (priv->button));
hbox = gtk_button_get_child (GTK_BUTTON (priv->button));
frame = priv->frame;
arrow = priv->arrow;
current_child = gtk_widget_get_first_child (frame);
......
......@@ -301,7 +301,7 @@ update_window_buttons (GtkWindowControls *self)
gtk_widget_add_css_class (button, "minimize");
image = gtk_image_new_from_icon_name ("window-minimize-symbolic");
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_widget_set_can_focus (button, FALSE);
gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
"window.minimize");
......@@ -322,7 +322,7 @@ update_window_buttons (GtkWindowControls *self)
gtk_widget_add_css_class (button, "maximize");
image = gtk_image_new_from_icon_name (icon_name);
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_widget_set_can_focus (button, FALSE);
gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
"window.toggle-maximized");
......@@ -339,7 +339,7 @@ update_window_buttons (GtkWindowControls *self)
image = gtk_image_new_from_icon_name ("window-close-symbolic");
gtk_widget_add_css_class (button, "close");
g_object_set (image, "use-fallback", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_button_set_child (GTK_BUTTON (button), image);
gtk_widget_set_can_focus (button, FALSE);
gtk_actionable_set_action_name (GTK_ACTIONABLE (button),
"window.close");
......
......@@ -133,10 +133,10 @@ variant_editor_set_value (GtkWidget *editor,
GtkWidget *child;
gtk_toggle_button_set_active (tb, g_variant_get_boolean (value));
child = gtk_bin_get_child (GTK_BIN (tb));
child = gtk_button_get_child (GTK_BUTTON (tb));
gtk_label_set_text (GTK_LABEL (child),
g_variant_get_boolean (value) ? "TRUE" : "FALSE");
}
g_variant_get_boolean (value) ? "TRUE" : "FALSE");
}
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
{
GtkEntry *entry = GTK_ENTRY (editor);
......
......@@ -1025,7 +1025,7 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
gtk_container_add (GTK_CONTAINER (child), title);
arrow = gtk_builtin_icon_new ("expander");
gtk_container_add (GTK_CONTAINER (title), arrow);
gtk_button_set_child (GTK_BUTTON (title), arrow);
}
else
{
......
......@@ -194,7 +194,7 @@ main (int argc,
gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("│Xyj,Ö"));
gtk_container_add (GTK_CONTAINER (box), gtk_image_new_from_icon_name ("face-sad"));
gtk_container_add (GTK_CONTAINER (button), box);
gtk_button_set_child (GTK_BUTTON (button), box);
set_font_size (button, i);
......@@ -286,7 +286,7 @@ main (int argc,
gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("│Xyj,Ö"));
gtk_container_add (GTK_CONTAINER (box), gtk_image_new_from_icon_name ("face-sad"));
gtk_container_add (GTK_CONTAINER (button), box);
gtk_button_set_child (GTK_BUTTON (button), box);
set_font_size (button, i);
......@@ -377,7 +377,7 @@ main (int argc,
image = gtk_image_new_from_icon_name ("face-sad");
gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
gtk_container_add (GTK_CONTAINER (box), image);
gtk_container_add (GTK_CONTAINER (button), box);
gtk_button_set_child (GTK_BUTTON (button), box);
if (i == 0)
g_signal_connect (spin2, "value-changed", (GCallback)image_size_value_changed, image);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment