Skip to content
Permalink
Browse files

Replace deprecated gtk_menu_popup

Replace deprecated gtk_menu_popup in eel-editable-label,caja-dnd, emblem-sidebar,caja-side-pane, fm-tree-view, caja-navigation-window-pane, and caja-zoom-control
  • Loading branch information...
raveit65 authored and lukefromdc committed May 5, 2018
1 parent ded490e commit ddf6f38db4e842abecd4f2ee77012050822b3775
@@ -3047,37 +3047,6 @@ popup_menu_detach (GtkWidget *attach_widget,
label->popup_menu = NULL;
}

static void
popup_position_func (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data)
{
EelEditableLabel *label;
GtkWidget *widget;
GtkRequisition req;
GtkAllocation allocation;
gint scale;

label = EEL_EDITABLE_LABEL (user_data);
widget = GTK_WIDGET (label);

g_assert (gtk_widget_get_realized (widget));

gdk_window_get_origin (gtk_widget_get_window (widget), x, y);

gtk_widget_get_preferred_size (widget, &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
scale = gtk_widget_get_scale_factor (widget);

*x += allocation.width / 2;
*y += allocation.height;

*x = CLAMP (*x, 0, MAX (0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - req.width));
*y = CLAMP (*y, 0, MAX (0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - req.height));
}

static void
eel_editable_label_toggle_overwrite (EelEditableLabel *label)
{
@@ -3157,14 +3126,10 @@ popup_targets_received (GtkClipboard *clipboard,
label->popup_menu);

if (info->button)
gtk_menu_popup (GTK_MENU (label->popup_menu), NULL, NULL,
NULL, NULL,
info->button, info->time);
gtk_menu_popup_at_pointer (GTK_MENU (label->popup_menu), NULL);
else
{
gtk_menu_popup (GTK_MENU (label->popup_menu), NULL, NULL,
popup_position_func, label,
info->button, info->time);
gtk_menu_popup_at_pointer (GTK_MENU (label->popup_menu), NULL);
gtk_menu_shell_select_first (GTK_MENU_SHELL (label->popup_menu), FALSE);
}
}
@@ -785,6 +785,7 @@ caja_drag_drop_action_ask (GtkWidget *widget,
GtkWidget *menu;
GtkWidget *menu_item;
DropActionMenuData damd;
GdkEvent *event;

/* Create the menu and set the sensitivity of the items based on the
* allowed actions.
@@ -827,8 +828,7 @@ caja_drag_drop_action_ask (GtkWidget *widget,

gtk_grab_add (menu);

gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
NULL, NULL, 0, GDK_CURRENT_TIME);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (const GdkEvent*) event);

g_main_loop_run (damd.loop);

@@ -849,6 +849,7 @@ caja_drag_drop_background_ask (GtkWidget *widget,
GtkWidget *menu;
GtkWidget *menu_item;
DropActionMenuData damd;
GdkEvent *event;

/* Create the menu and set the sensitivity of the items based on the
* allowed actions.
@@ -881,8 +882,7 @@ caja_drag_drop_background_ask (GtkWidget *widget,

gtk_grab_add (menu);

gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
NULL, NULL, 0, GDK_CURRENT_TIME);
gtk_menu_popup_at_pointer (GTK_MENU (menu), (const GdkEvent*) event);

g_main_loop_run (damd.loop);

@@ -187,10 +187,8 @@ caja_emblem_sidebar_button_press_cb (GtkWidget *widget,
gtk_widget_set_sensitive (emblem_sidebar->details->popup_rename,
caja_emblem_can_rename_emblem (keyword));


gtk_menu_popup (GTK_MENU (emblem_sidebar->details->popup),
NULL, NULL, NULL, NULL, event->button,
event->time);
gtk_menu_popup_at_pointer (GTK_MENU (emblem_sidebar->details->popup),
(const GdkEvent*) event);
}

return TRUE;
@@ -358,7 +358,6 @@ notebook_popup_menu_show (CajaNavigationWindowPane *pane,
{
GtkWidget *popup;
GtkWidget *item;
int button, event_time;
gboolean can_move_left, can_move_right;
CajaNotebook *notebook;

@@ -409,24 +408,13 @@ notebook_popup_menu_show (CajaNavigationWindowPane *pane,

gtk_widget_show_all (popup);

if (event)
{
button = event->button;
event_time = event->time;
}
else
{
button = 0;
event_time = gtk_get_current_event_time ();
}

/* TODO is this correct? */
gtk_menu_attach_to_widget (GTK_MENU (popup),
pane->notebook,
NULL);

gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
button, event_time);
gtk_menu_popup_at_pointer (GTK_MENU (popup),
(const GdkEvent*) event);
}

/* emitted when the user clicks the "close" button of tabs */
@@ -228,9 +228,11 @@ select_button_press_callback (GtkWidget *widget,
gtk_widget_grab_focus (widget);

gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_menu_popup (GTK_MENU (side_pane->details->menu),
NULL, NULL, menu_position_under, widget,
event->button, event->time);
gtk_menu_popup_at_widget (GTK_MENU (side_pane->details->menu),
widget,
GDK_GRAVITY_SOUTH_WEST,
GDK_GRAVITY_NORTH_WEST,
(const GdkEvent*) event);

return TRUE;
}
@@ -252,9 +254,11 @@ select_button_key_press_callback (GtkWidget *widget,
event->keyval == GDK_KEY_KP_Enter)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
gtk_menu_popup (GTK_MENU (side_pane->details->menu),
NULL, NULL, menu_position_under, widget,
1, event->time);
gtk_menu_popup_at_widget (GTK_MENU (side_pane->details->menu),
widget,
GDK_GRAVITY_SOUTH_WEST,
GDK_GRAVITY_NORTH_WEST,
(const GdkEvent*) event);
return TRUE;
}

@@ -132,84 +132,19 @@ zoom_popup_menu_show (GdkEventButton *event, CajaZoomControl *zoom_control)
event);
}

static void
menu_position_under_widget (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data)
{
GtkWidget *widget;
GtkWidget *container;
GtkRequisition req;
GtkRequisition menu_req;
GdkRectangle monitor;
GdkMonitor *monitor_num;
GdkDisplay *display;
GtkAllocation allocation;

widget = GTK_WIDGET (user_data);
g_assert (GTK_IS_WIDGET (widget));

container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
g_assert (container != NULL);

gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
gtk_widget_get_preferred_size (widget, &req, NULL);
gtk_widget_get_allocation (widget, &allocation);

display = gtk_widget_get_display (GTK_WIDGET (menu));
monitor_num = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (widget));
if (monitor_num == NULL)
monitor_num = gdk_display_get_monitor (display, 0);
gdk_monitor_get_geometry (monitor_num, &monitor);

gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
if (!gtk_widget_get_has_window (widget))
{
*x += allocation.x;
*y += allocation.y;
}

if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
{
*x += allocation.width - req.width;
}
else
{
*x += req.width - menu_req.width;
}

if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
{
*y += allocation.height;
}
else if ((*y - menu_req.height) >= monitor.y)
{
*y -= menu_req.height;
}
else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
{
*y += allocation.height;
}
else
{
*y -= menu_req.height;
}

*push_in = FALSE;
}


static void
zoom_popup_menu (GtkWidget *widget, CajaZoomControl *zoom_control)
{
GtkMenu *menu;
GdkEvent *event;

menu = create_zoom_menu (zoom_control);
gtk_menu_popup (menu, NULL, NULL,
menu_position_under_widget, widget,
0, gtk_get_current_event_time ());
gtk_menu_popup_at_widget (menu,
widget,
GDK_GRAVITY_SOUTH_WEST,
GDK_GRAVITY_NORTH_WEST,
(const GdkEvent*) event);

gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}

@@ -861,9 +861,8 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
gtk_widget_hide (view->details->popup_unmount_separator);
}

gtk_menu_popup (GTK_MENU (view->details->popup),
NULL, NULL, NULL, NULL,
event->button, event->time);
gtk_menu_popup_at_pointer (GTK_MENU (view->details->popup),
(const GdkEvent*) event);

gtk_tree_view_set_cursor (view->details->tree_widget, cursor_path, NULL, FALSE);
gtk_tree_path_free (cursor_path);

0 comments on commit ddf6f38

Please sign in to comment.
You can’t perform that action at this time.