mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 13:30:19 +00:00
Use gtk_popover_set_child throughout
Replace all uses of gtk_container_add on popovers by gtk_popover_set_child.
This commit is contained in:
parent
ee284a560a
commit
8e261056b9
@ -161,7 +161,7 @@ create_menu_button (void)
|
||||
GtkWidget *w = gtk_menu_button_new ();
|
||||
GtkWidget *popover = gtk_popover_new ();
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (popover), gtk_button_new_with_label ("Hey!"));
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), gtk_button_new_with_label ("Hey!"));
|
||||
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (w), popover);
|
||||
g_signal_connect (w, "map", G_CALLBACK (mapped), NULL);
|
||||
|
@ -440,7 +440,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
g_signal_connect (apply, "clicked", G_CALLBACK (reconfigure), NULL);
|
||||
|
||||
popover = gtk_popover_new ();
|
||||
gtk_container_add (GTK_CONTAINER (popover), tweaks);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), tweaks);
|
||||
|
||||
tweak = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (tweak), popover);
|
||||
|
@ -442,7 +442,7 @@ show_variations (GtkEmojiChooser *chooser,
|
||||
gtk_flow_box_set_activate_on_single_click (GTK_FLOW_BOX (box), TRUE);
|
||||
gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (box), GTK_SELECTION_NONE);
|
||||
g_object_set (box, "accept-unpaired-release", TRUE, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (popover), view);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), view);
|
||||
gtk_container_add (GTK_CONTAINER (view), box);
|
||||
|
||||
g_signal_connect (box, "child-activated", G_CALLBACK (emoji_activated), parent_popover);
|
||||
|
@ -600,7 +600,7 @@ gtk_entry_completion_constructed (GObject *object)
|
||||
gtk_widget_add_controller (priv->popup_window, controller);
|
||||
|
||||
popup_frame = gtk_frame_new (NULL);
|
||||
gtk_container_add (GTK_CONTAINER (priv->popup_window), popup_frame);
|
||||
gtk_popover_set_child (GTK_POPOVER (priv->popup_window), popup_frame);
|
||||
|
||||
priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_frame_set_child (GTK_FRAME (popup_frame), priv->vbox);
|
||||
|
@ -4245,8 +4245,9 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
|
||||
{
|
||||
GtkWidget *parent = gtk_widget_get_parent (page->menu_label);
|
||||
|
||||
gtk_notebook_menu_label_unparent (parent, NULL);
|
||||
gtk_container_remove (GTK_CONTAINER (notebook->menu), parent);
|
||||
if (parent)
|
||||
gtk_notebook_menu_label_unparent (parent, NULL);
|
||||
gtk_popover_set_child (GTK_POPOVER (notebook->menu), NULL);
|
||||
|
||||
gtk_widget_queue_resize (notebook->menu);
|
||||
}
|
||||
@ -6370,6 +6371,7 @@ gtk_notebook_popup_enable (GtkNotebook *notebook)
|
||||
gtk_widget_set_parent (notebook->menu, notebook->tabs_widget);
|
||||
|
||||
notebook->menu_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
g_object_ref_sink (notebook->menu_box);
|
||||
gtk_popover_menu_add_submenu (GTK_POPOVER_MENU (notebook->menu), notebook->menu_box, "main");
|
||||
|
||||
for (list = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, FALSE);
|
||||
|
@ -2296,7 +2296,7 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
|
||||
g_signal_connect (popover, "destroy", G_CALLBACK (on_rename_popover_destroy), sidebar);
|
||||
gtk_popover_set_position (GTK_POPOVER (popover), GTK_POS_RIGHT);
|
||||
grid = gtk_grid_new ();
|
||||
gtk_container_add (GTK_CONTAINER (popover), grid);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), grid);
|
||||
g_object_set (grid,
|
||||
"margin-start", 10,
|
||||
"margin-end", 10,
|
||||
|
@ -265,7 +265,7 @@ gtk_popover_menu_init (GtkPopoverMenu *popover)
|
||||
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
|
||||
gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
|
||||
gtk_stack_set_interpolate_size (GTK_STACK (stack), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (popover), stack);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), stack);
|
||||
g_signal_connect (stack, "notify::visible-child-name",
|
||||
G_CALLBACK (visible_submenu_changed), popover);
|
||||
|
||||
@ -328,9 +328,7 @@ gtk_popover_menu_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (object));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (object));
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -354,9 +352,7 @@ gtk_popover_menu_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (object));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (object));
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
@ -588,7 +584,7 @@ gtk_popover_menu_open_submenu (GtkPopoverMenu *popover,
|
||||
|
||||
g_return_if_fail (GTK_IS_POPOVER_MENU (popover));
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
|
||||
}
|
||||
|
||||
@ -597,9 +593,7 @@ gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
|
||||
GtkWidget *submenu,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
gtk_stack_add_named (GTK_STACK (stack), submenu, name);
|
||||
}
|
||||
|
||||
@ -689,7 +683,7 @@ gtk_popover_menu_set_menu_model (GtkPopoverMenu *popover,
|
||||
GtkWidget *stack;
|
||||
GtkWidget *child;
|
||||
|
||||
stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
while ((child = gtk_widget_get_first_child (stack)))
|
||||
gtk_container_remove (GTK_CONTAINER (stack), child);
|
||||
|
||||
|
@ -952,7 +952,7 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self)
|
||||
G_CALLBACK (gtk_shortcuts_window__list_box__row_activated),
|
||||
self,
|
||||
G_CONNECT_SWAPPED);
|
||||
gtk_container_add (GTK_CONTAINER (priv->popover), GTK_WIDGET (priv->list_box));
|
||||
gtk_popover_set_child (GTK_POPOVER (priv->popover), GTK_WIDGET (priv->list_box));
|
||||
|
||||
priv->search_entry = GTK_SEARCH_ENTRY (gtk_search_entry_new ());
|
||||
gtk_container_add (GTK_CONTAINER (priv->search_bar), GTK_WIDGET (priv->search_entry));
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "gtkcellarea.h"
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellview.h"
|
||||
#include "gtkbin.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
@ -231,7 +230,7 @@ gtk_tree_popover_add_submenu (GtkTreePopover *popover,
|
||||
GtkWidget *submenu,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
gtk_stack_add_named (GTK_STACK (stack), submenu, name);
|
||||
}
|
||||
|
||||
@ -239,8 +238,7 @@ static GtkWidget *
|
||||
gtk_tree_popover_get_submenu (GtkTreePopover *popover,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
return gtk_stack_get_child_by_name (GTK_STACK (stack), name);
|
||||
}
|
||||
|
||||
@ -248,7 +246,7 @@ void
|
||||
gtk_tree_popover_open_submenu (GtkTreePopover *popover,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), name);
|
||||
}
|
||||
|
||||
@ -261,7 +259,7 @@ gtk_tree_popover_init (GtkTreePopover *popover)
|
||||
gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE);
|
||||
gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
|
||||
gtk_stack_set_interpolate_size (GTK_STACK (stack), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (popover), stack);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), stack);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (popover), GTK_STYLE_CLASS_MENU);
|
||||
}
|
||||
@ -466,7 +464,7 @@ static GtkWidget *
|
||||
gtk_tree_popover_get_path_item (GtkTreePopover *popover,
|
||||
GtkTreePath *search)
|
||||
{
|
||||
GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
GtkWidget *stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
GtkWidget *item = NULL;
|
||||
GList *children, *l;
|
||||
|
||||
@ -733,7 +731,9 @@ gtk_tree_popover_populate (GtkTreePopover *popover)
|
||||
static void
|
||||
rebuild_menu (GtkTreePopover *popover)
|
||||
{
|
||||
GtkWidget *stack = gtk_bin_get_child (GTK_BIN (popover));
|
||||
GtkWidget *stack;
|
||||
|
||||
stack = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
gtk_container_foreach (GTK_CONTAINER (stack), (GtkCallback) gtk_widget_destroy, NULL);
|
||||
|
||||
if (popover->model)
|
||||
|
@ -9999,7 +9999,7 @@ gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view)
|
||||
g_signal_connect (tree_view->search_entry, "changed",
|
||||
G_CALLBACK (gtk_tree_view_search_changed), tree_view);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (tree_view->search_popover), tree_view->search_entry);
|
||||
gtk_popover_set_child (GTK_POPOVER (tree_view->search_popover), tree_view->search_entry);
|
||||
|
||||
gtk_widget_realize (tree_view->search_entry);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ show_node_prop_editor (NodePropEditor *npe)
|
||||
|
||||
editor = gtk_inspector_prop_editor_new (G_OBJECT (npe->node), npe->prop_name, NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (popover), editor);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), editor);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (popover));
|
||||
|
||||
|
@ -573,7 +573,7 @@ flags_changed (GObject *object, GParamSpec *pspec, gpointer data)
|
||||
g_free (str);
|
||||
|
||||
popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (data));
|
||||
sw = gtk_bin_get_child (GTK_BIN (popover));
|
||||
sw = gtk_popover_get_child (GTK_POPOVER (popover));
|
||||
viewport = gtk_bin_get_child (GTK_BIN (sw));
|
||||
box = gtk_viewport_get_child (GTK_VIEWPORT (viewport));
|
||||
children = gtk_container_get_children (GTK_CONTAINER (box));
|
||||
@ -943,12 +943,12 @@ property_editor (GObject *object,
|
||||
GFlagsClass *fclass;
|
||||
gint j;
|
||||
|
||||
popover = gtk_popover_new ();
|
||||
popover = gtk_popover_new ();
|
||||
prop_edit = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (popover), sw);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), sw);
|
||||
g_object_set (sw,
|
||||
"hexpand", TRUE,
|
||||
"vexpand", TRUE,
|
||||
@ -1006,17 +1006,17 @@ property_editor (GObject *object,
|
||||
else if (type == G_TYPE_PARAM_OBJECT &&
|
||||
g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (spec), G_TYPE_LIST_MODEL))
|
||||
{
|
||||
GtkWidget *popover;
|
||||
GtkWidget *box;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *popover;
|
||||
GtkWidget *box;
|
||||
GtkWidget *sw;
|
||||
GListModel *model;
|
||||
|
||||
popover = gtk_popover_new ();
|
||||
popover = gtk_popover_new ();
|
||||
prop_edit = gtk_menu_button_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (prop_edit), popover);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (popover), sw);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), sw);
|
||||
g_object_set (sw,
|
||||
"hexpand", TRUE,
|
||||
"vexpand", TRUE,
|
||||
|
@ -1175,7 +1175,7 @@ node_property_activated (GtkTreeView *tv,
|
||||
gtk_widget_set_margin_end (image, 20);
|
||||
gtk_widget_set_margin_top (image, 20);
|
||||
gtk_widget_set_margin_bottom (image, 20);
|
||||
gtk_container_add (GTK_CONTAINER (popover), image);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), image);
|
||||
gtk_popover_popup (GTK_POPOVER (popover));
|
||||
|
||||
g_signal_connect (popover, "unmap", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
@ -199,7 +199,7 @@ main (int argc, char *argv[])
|
||||
gtk_menu_button_set_direction (GTK_MENU_BUTTON (button), GTK_ARROW_UP);
|
||||
popover = gtk_popover_new ();
|
||||
label = gtk_label_new ("Popovers work too!");
|
||||
gtk_container_add (GTK_CONTAINER (popover), label);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), label);
|
||||
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||
|
@ -177,7 +177,7 @@ ask_actions (GdkDrop *drop,
|
||||
g_object_set_data (G_OBJECT (image), "popover", popover);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (popover), box);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), box);
|
||||
button = gtk_button_new_with_label ("Copy");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (do_copy), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (box), button);
|
||||
|
@ -221,7 +221,7 @@ scrollable_policy (void)
|
||||
gtk_container_add (GTK_CONTAINER (cntl), widget);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
gtk_container_add (GTK_CONTAINER (popover), vbox);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), vbox);
|
||||
|
||||
/* Popover's scrolled window */
|
||||
swindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
@ -424,7 +424,7 @@ main (int argc, char *argv[])
|
||||
popover = gtk_popover_new ();
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (popover), box2);
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), box2);
|
||||
|
||||
button = gtk_label_new ("Hidden here");
|
||||
custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
|
@ -44,7 +44,7 @@ test_show_popover (void)
|
||||
window = gtk_window_new ();
|
||||
button = gtk_menu_button_new ();
|
||||
popover = gtk_popover_new ();
|
||||
gtk_container_add (GTK_CONTAINER (popover), gtk_label_new ("Nu?"));
|
||||
gtk_popover_set_child (GTK_POPOVER (popover), gtk_label_new ("Nu?"));
|
||||
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), popover);
|
||||
gtk_container_add (GTK_CONTAINER (window), button);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user