Commit ab200d0b authored by Niels De Graef's avatar Niels De Graef 😁
Browse files

app: Remove old GimpUiManager popup API

The code used `gtk_menu_popup()`, which was deprecated a while ago, as
it was broken on certain GDK backends, like Wayland.

Fixes #5319
parent bdab4fce
Pipeline #340516 passed with stages
in 32 minutes and 57 seconds
......@@ -445,26 +445,6 @@ gimp_editor_create_menu (GimpEditor *editor,
editor->priv->popup_data = popup_data;
}
gboolean
gimp_editor_popup_menu (GimpEditor *editor,
GimpMenuPositionFunc position_func,
gpointer position_data)
{
g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE);
if (editor->priv->ui_manager && editor->priv->ui_path)
{
gimp_ui_manager_update (editor->priv->ui_manager, editor->priv->popup_data);
gimp_ui_manager_ui_popup (editor->priv->ui_manager, editor->priv->ui_path,
GTK_WIDGET (editor),
position_func, position_data,
NULL, NULL);
return TRUE;
}
return FALSE;
}
gboolean
gimp_editor_popup_menu_at_pointer (GimpEditor *editor,
const GdkEvent *trigger_event)
......
......@@ -55,9 +55,6 @@ void gimp_editor_create_menu (GimpEditor *editor,
const gchar *menu_identifier,
const gchar *ui_path,
gpointer popup_data);
gboolean gimp_editor_popup_menu (GimpEditor *editor,
GimpMenuPositionFunc position_func,
gpointer position_data);
gboolean gimp_editor_popup_menu_at_pointer (GimpEditor *editor,
const GdkEvent *trigger_event);
gboolean gimp_editor_popup_menu_at_rect (GimpEditor *editor,
......
......@@ -92,11 +92,6 @@ static void gimp_ui_manager_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data);
static void gimp_ui_manager_menu_pos (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer data);
static void gimp_ui_manager_delete_popdown_data (GtkWidget *widget,
GimpUIManager *manager);
static void gimp_ui_manager_item_realize (GtkWidget *widget,
......@@ -630,102 +625,6 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
manager->registered_uis = g_list_prepend (manager->registered_uis, entry);
}
typedef struct
{
guint x;
guint y;
} MenuPos;
static void
menu_pos_free (MenuPos *pos)
{
g_slice_free (MenuPos, pos);
}
void
gimp_ui_manager_ui_popup (GimpUIManager *manager,
const gchar *ui_path,
GtkWidget *parent,
GimpMenuPositionFunc position_func,
gpointer position_data,
GDestroyNotify popdown_func,
gpointer popdown_data)
{
GtkWidget *menu;
GdkEvent *current_event;
gint x, y;
guint button;
guint32 activate_time;
MenuPos *menu_pos;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
menu = gimp_ui_manager_get_widget (manager, ui_path);
if (GTK_IS_MENU_ITEM (menu))
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
if (! menu)
return;
g_return_if_fail (GTK_IS_MENU (menu));
if (! position_func)
{
position_func = gimp_ui_manager_menu_position;
position_data = parent;
}
(* position_func) (GTK_MENU (menu), &x, &y, position_data);
current_event = gtk_get_current_event ();
if (current_event && current_event->type == GDK_BUTTON_PRESS)
{
GdkEventButton *bevent = (GdkEventButton *) current_event;
button = bevent->button;
activate_time = bevent->time;
}
else
{
button = 0;
activate_time = 0;
}
if (current_event)
gdk_event_free (current_event);
menu_pos = g_object_get_data (G_OBJECT (menu), "menu-pos");
if (! menu_pos)
{
menu_pos = g_slice_new0 (MenuPos);
g_object_set_data_full (G_OBJECT (menu), "menu-pos", menu_pos,
(GDestroyNotify) menu_pos_free);
}
menu_pos->x = x;
menu_pos->y = y;
if (popdown_func && popdown_data)
{
g_object_set_data_full (G_OBJECT (manager), "popdown-data",
popdown_data, popdown_func);
g_signal_connect (menu, "selection-done",
G_CALLBACK (gimp_ui_manager_delete_popdown_data),
manager);
}
gtk_menu_popup (GTK_MENU (menu),
NULL, NULL,
gimp_ui_manager_menu_pos, menu_pos,
button, activate_time);
}
void
gimp_ui_manager_ui_popup_at_widget (GimpUIManager *manager,
const gchar *ui_path,
......@@ -1007,73 +906,6 @@ gimp_ui_manager_entry_ensure (GimpUIManager *manager,
return entry;
}
static void
gimp_ui_manager_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data)
{
GdkSeat *seat;
GdkDevice *device;
GdkScreen *screen;
GtkRequisition requisition;
GdkRectangle workarea;
gint pointer_x;
gint pointer_y;
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (x != NULL);
g_return_if_fail (y != NULL);
g_return_if_fail (GTK_IS_WIDGET (data));
seat = gdk_display_get_default_seat (gtk_widget_get_display (data));
device = gdk_seat_get_pointer (seat);
gdk_device_get_position (device, &screen, &pointer_x, &pointer_y);
gdk_monitor_get_workarea (gimp_get_monitor_at_pointer (), &workarea);
gtk_menu_set_screen (menu, screen);
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
if (gtk_widget_get_direction (GTK_WIDGET (menu)) == GTK_TEXT_DIR_RTL)
{
*x = pointer_x - 2 - requisition.width;
if (*x < workarea.x)
*x = pointer_x + 2;
}
else
{
*x = pointer_x + 2;
if (*x + requisition.width > workarea.x + workarea.width)
*x = pointer_x - 2 - requisition.width;
}
*y = pointer_y + 2;
if (*y + requisition.height > workarea.y + workarea.height)
*y = pointer_y - 2 - requisition.height;
if (*x < workarea.x) *x = workarea.x;
if (*y < workarea.y) *y = workarea.y;
}
static void
gimp_ui_manager_menu_pos (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer data)
{
MenuPos *menu_pos = data;
*x = menu_pos->x;
*y = menu_pos->y;
}
static void
gimp_ui_manager_delete_popdown_data (GtkWidget *widget,
GimpUIManager *manager)
......
......@@ -126,13 +126,6 @@ void gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *basename,
GimpUIManagerSetupFunc setup_func);
void gimp_ui_manager_ui_popup (GimpUIManager *manager,
const gchar *ui_path,
GtkWidget *parent,
GimpMenuPositionFunc position_func,
gpointer position_data,
GDestroyNotify popdown_func,
gpointer popdown_data);
void gimp_ui_manager_ui_popup_at_widget
(GimpUIManager *manager,
const gchar *ui_path,
......
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