gtk/popover: Use gtk_popover_present() instead of going via GtkNative

This makes it more explicit that managers of popovers make it "present".
This commit is contained in:
Jonas Ådahl 2020-12-04 09:20:50 +01:00
parent f7fceab40b
commit 2cddec7798
22 changed files with 46 additions and 32 deletions

View File

@ -97,9 +97,9 @@ demo3_widget_size_allocate (GtkWidget *widget,
/* Since we are not using a layout manager (who would do this
* for us), we need to allocate a size for our menu by calling
* gtk_native_check_resize().
* gtk_popover_present().
*/
gtk_native_check_resize (GTK_NATIVE (self->menu));
gtk_popover_present (GTK_POPOVER (self->menu));
}
static void

View File

@ -474,7 +474,7 @@ suggestion_entry_size_allocate (GtkWidget *widget,
gtk_widget_set_size_request (self->popup, gtk_widget_get_allocated_width (GTK_WIDGET (self)), -1);
gtk_widget_queue_resize (self->popup);
gtk_native_check_resize (GTK_NATIVE (self->popup));
gtk_popover_present (GTK_POPOVER (self->popup));
}
static gboolean

View File

@ -6112,6 +6112,7 @@ GtkPopover
gtk_popover_new
gtk_popover_popup
gtk_popover_popdown
gtk_popover_present
gtk_popover_set_child
gtk_popover_get_child
gtk_popover_set_pointing_to

View File

@ -322,7 +322,7 @@ swatch_size_allocate (GtkWidget *widget,
}, -1);
if (swatch->popover)
gtk_native_check_resize (GTK_NATIVE (swatch->popover));
gtk_popover_present (GTK_POPOVER (swatch->popover));
}
static void

View File

@ -144,7 +144,7 @@ gtk_column_view_title_size_allocate (GtkWidget *widget,
}
if (self->popup_menu)
gtk_native_check_resize (GTK_NATIVE (self->popup_menu));
gtk_popover_present (GTK_POPOVER (self->popup_menu));
}
static void

View File

@ -376,7 +376,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gtk_widget_set_size_request (priv->popup_widget,
MAX (width, menu_width), -1);
gtk_native_check_resize (GTK_NATIVE (priv->popup_widget));
gtk_popover_present (GTK_POPOVER (priv->popup_widget));
}
static void

View File

@ -383,7 +383,7 @@ gtk_drop_down_size_allocate (GtkWidget *widget,
gtk_widget_set_size_request (self->popup, width, -1);
gtk_widget_queue_resize (self->popup);
gtk_native_check_resize (GTK_NATIVE (self->popup));
gtk_popover_present (GTK_POPOVER (self->popup));
}
static gboolean

View File

@ -113,7 +113,7 @@ gtk_emoji_chooser_child_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_emoji_chooser_child_parent_class)->size_allocate (widget, width, height, baseline);
if (child->variations)
gtk_native_check_resize (GTK_NATIVE (child->variations));
gtk_popover_present (GTK_POPOVER (child->variations));
}
static gboolean

View File

@ -1150,7 +1150,8 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
NULL, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
}
gtk_native_check_resize (GTK_NATIVE (completion->popup_window));
gtk_popover_present (GTK_POPOVER (completion->popup_window));
}
static void

View File

@ -7225,10 +7225,11 @@ gtk_file_chooser_widget_size_allocate (GtkWidget *widget,
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget);
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline);
if (impl->browse_files_popover)
gtk_native_check_resize (GTK_NATIVE (impl->browse_files_popover));
gtk_popover_present (GTK_POPOVER (impl->browse_files_popover));
if (impl->rename_file_popover)
gtk_native_check_resize (GTK_NATIVE (impl->rename_file_popover));
gtk_popover_present (GTK_POPOVER (impl->rename_file_popover));
}
static void

View File

@ -3276,7 +3276,7 @@ gtk_label_size_allocate (GtkWidget *widget,
}
if (self->popup_menu)
gtk_native_check_resize (GTK_NATIVE (self->popup_menu));
gtk_popover_present (GTK_POPOVER (self->popup_menu));
}
static void

View File

@ -77,6 +77,7 @@
#include "gtklayoutchild.h"
#include "gtkwidgetprivate.h"
#include "gtknative.h"
#include "gtkpopover.h"
#ifdef G_ENABLE_DEBUG
#define LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED(m,method) G_STMT_START { \
@ -363,7 +364,9 @@ allocate_native_children (GtkWidget *widget)
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
if (GTK_IS_NATIVE (child))
if (GTK_IS_POPOVER (child))
gtk_popover_present (GTK_POPOVER (child));
else if (GTK_IS_NATIVE (child))
gtk_native_check_resize (GTK_NATIVE (child));
}
}

View File

@ -319,7 +319,7 @@ gtk_menu_button_size_allocate (GtkWidget *widget,
&(GtkAllocation) { 0, 0, width, height },
baseline);
if (self->popover)
gtk_native_check_resize (GTK_NATIVE (self->popover));
gtk_popover_present (GTK_POPOVER (self->popover));
}
static gboolean

View File

@ -4076,10 +4076,10 @@ gtk_places_sidebar_size_allocate (GtkWidget *widget,
baseline);
if (sidebar->popover)
gtk_native_check_resize (GTK_NATIVE (sidebar->popover));
gtk_popover_present (GTK_POPOVER (sidebar->popover));
if (sidebar->rename_popover)
gtk_native_check_resize (GTK_NATIVE (sidebar->rename_popover));
gtk_popover_present (GTK_POPOVER (sidebar->rename_popover));
}
static void

View File

@ -36,6 +36,7 @@
#include "gtkstack.h"
#include "gtktypebuiltins.h"
#include "gtknative.h"
#include "gtkpopover.h"
#else
#include <gtk/gtk.h>
#endif
@ -319,7 +320,7 @@ gtk_places_view_row_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_places_view_row_parent_class)->size_allocate (widget, width, height, baseline);
if (menu)
gtk_native_check_resize (GTK_NATIVE (menu));
gtk_popover_present (GTK_POPOVER (menu));
}
static void

View File

@ -577,10 +577,9 @@ present_popup (GtkPopover *popover)
return FALSE;
}
static void
gtk_popover_native_check_resize (GtkNative *native)
void
gtk_popover_present (GtkPopover *popover)
{
GtkPopover *popover = GTK_POPOVER (native);
GtkWidget *widget = GTK_WIDGET (popover);
if (!_gtk_widget_get_alloc_needed (widget))
@ -589,6 +588,11 @@ gtk_popover_native_check_resize (GtkNative *native)
present_popup (popover);
}
static void
gtk_popover_native_check_resize (GtkNative *native)
{
}
static void
maybe_request_motion_event (GtkPopover *popover)
{

View File

@ -121,6 +121,9 @@ GDK_AVAILABLE_IN_ALL
void gtk_popover_set_default_widget (GtkPopover *popover,
GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_popover_present (GtkPopover *popover);
G_END_DECLS

View File

@ -320,7 +320,7 @@ gtk_popover_menu_bar_item_size_allocate (GtkWidget *widget,
&(GtkAllocation) { 0, 0, width, height },
baseline);
gtk_native_check_resize (GTK_NATIVE (item->popover));
gtk_popover_present (GTK_POPOVER (item->popover));
}
static void

View File

@ -1001,5 +1001,5 @@ gtk_scale_button_size_allocate (GtkWidget *widget,
&(GtkAllocation) { 0, 0, width, height },
baseline);
gtk_native_check_resize (GTK_NATIVE (priv->dock));
gtk_popover_present (GTK_POPOVER (priv->dock));
}

View File

@ -2448,21 +2448,21 @@ gtk_text_size_allocate (GtkWidget *widget,
chooser = g_object_get_data (G_OBJECT (self), "gtk-emoji-chooser");
if (chooser)
gtk_native_check_resize (GTK_NATIVE (chooser));
gtk_popover_present (GTK_POPOVER (chooser));
gtk_text_update_handles (self);
if (priv->emoji_completion)
gtk_native_check_resize (GTK_NATIVE (priv->emoji_completion));
gtk_popover_present (GTK_POPOVER (priv->emoji_completion));
if (priv->magnifier_popover)
gtk_native_check_resize (GTK_NATIVE (priv->magnifier_popover));
gtk_popover_present (GTK_POPOVER (priv->magnifier_popover));
if (priv->popup_menu)
gtk_native_check_resize (GTK_NATIVE (priv->popup_menu));
gtk_popover_present (GTK_POPOVER (priv->popup_menu));
if (priv->selection_bubble)
gtk_native_check_resize (GTK_NATIVE (priv->selection_bubble));
gtk_popover_present (GTK_POPOVER (priv->selection_bubble));
if (priv->text_handles[TEXT_HANDLE_CURSOR])
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_CURSOR]));

View File

@ -4528,13 +4528,13 @@ gtk_text_view_size_allocate (GtkWidget *widget,
chooser = g_object_get_data (G_OBJECT (text_view), "gtk-emoji-chooser");
if (chooser)
gtk_native_check_resize (GTK_NATIVE (chooser));
gtk_popover_present (GTK_POPOVER (chooser));
if (priv->magnifier_popover)
gtk_native_check_resize (GTK_NATIVE (priv->magnifier_popover));
gtk_popover_present (GTK_POPOVER (priv->magnifier_popover));
if (priv->popup_menu)
gtk_native_check_resize (GTK_NATIVE (priv->popup_menu));
gtk_popover_present (GTK_POPOVER (priv->popup_menu));
if (priv->text_handles[TEXT_HANDLE_CURSOR])
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_CURSOR]));
@ -4543,7 +4543,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
if (priv->selection_bubble)
gtk_native_check_resize (GTK_NATIVE (priv->selection_bubble));
gtk_popover_present (GTK_POPOVER (priv->selection_bubble));
}
static void

View File

@ -2654,7 +2654,7 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
}
if (priv->search_popover)
gtk_native_check_resize (GTK_NATIVE (priv->search_popover));
gtk_popover_present (GTK_POPOVER (priv->search_popover));
}
/* Grabs the focus and unsets the GTK_TREE_VIEW_DRAW_KEYFOCUS flag */