Commit bc7fa2f1 authored by Giovanni Panozzo's avatar Giovanni Panozzo

Fix many gtk deprecations

parent 33b56138
......@@ -49,7 +49,11 @@ static void remmina_rdp_event_on_focus_in(GtkWidget* widget, GdkEventKey* event,
rfContext* rfi = GET_PLUGIN_DATA(gp);
rdpInput* input;
GdkModifierType state;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice *keyboard = NULL;
if (!rfi || !rfi->connected || rfi->is_reconnecting)
......@@ -58,8 +62,13 @@ static void remmina_rdp_event_on_focus_in(GtkWidget* widget, GdkEventKey* event,
input = rfi->instance->input;
UINT32 toggle_keys_state = 0;
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(gdk_display_get_default());
keyboard = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(gdk_display_get_default());
keyboard = gdk_device_manager_get_client_pointer(manager);
#endif
gdk_window_get_device_position(gdk_get_default_root_window(), keyboard, NULL, NULL, &state);
if (state & GDK_LOCK_MASK)
......@@ -925,7 +934,11 @@ static BOOL remmina_rdp_event_set_pointer_position(RemminaProtocolWidget *gp, gi
TRACE_CALL("remmina_rdp_event_set_pointer_position");
GdkWindow *w, *nw;
gint nx, ny, wx, wy;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice *dev;
rfContext* rfi = GET_PLUGIN_DATA(gp);
......@@ -933,8 +946,14 @@ static BOOL remmina_rdp_event_set_pointer_position(RemminaProtocolWidget *gp, gi
return FALSE;
w = gtk_widget_get_window(rfi->drawing_area);
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(gdk_display_get_default());
dev = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(gdk_display_get_default());
dev = gdk_device_manager_get_client_pointer(manager);
#endif
nw = gdk_device_get_window_at_position(dev, NULL, NULL);
if (nw == w) {
......
......@@ -305,12 +305,22 @@ static void remmina_connection_holder_keyboard_ungrab(RemminaConnectionHolder* c
{
TRACE_CALL("remmina_connection_holder_keyboard_ungrab");
GdkDisplay *display;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice *keyboard = NULL;
display = gtk_widget_get_display(GTK_WIDGET(cnnhld->cnnwin));
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(display);
keyboard = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(display);
keyboard = gdk_device_manager_get_client_pointer(manager);
#endif
if (!cnnhld->cnnwin->priv->kbcaptured)
{
......@@ -328,7 +338,7 @@ static void remmina_connection_holder_keyboard_ungrab(RemminaConnectionHolder* c
#endif
#if GTK_CHECK_VERSION(3, 20, 0)
gdk_seat_ungrab(gdk_device_get_seat(keyboard));
gdk_seat_ungrab(seat);
#else
gdk_device_ungrab(keyboard, GDK_CURRENT_TIME);
#endif
......@@ -342,7 +352,11 @@ static void remmina_connection_holder_keyboard_grab(RemminaConnectionHolder* cnn
TRACE_CALL("remmina_connection_holder_keyboard_grab");
DECLARE_CNNOBJ
GdkDisplay *display;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice *keyboard = NULL;
if (cnnhld->cnnwin->priv->kbcaptured || !cnnhld->cnnwin->priv->mouse_pointer_entered)
......@@ -351,8 +365,13 @@ static void remmina_connection_holder_keyboard_grab(RemminaConnectionHolder* cnn
}
display = gtk_widget_get_display(GTK_WIDGET(cnnhld->cnnwin));
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(display);
keyboard = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(display);
keyboard = gdk_device_manager_get_client_pointer(manager);
#endif
if (keyboard != NULL)
{
......@@ -368,7 +387,7 @@ static void remmina_connection_holder_keyboard_grab(RemminaConnectionHolder* cnn
printf("DEBUG_KB_GRABBING: +++ grabbing\n");
#endif
#if GTK_CHECK_VERSION(3, 20, 0)
if (gdk_seat_grab(gdk_device_get_seat(keyboard), gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)),
if (gdk_seat_grab(seat, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)),
GDK_SEAT_CAPABILITY_KEYBOARD, FALSE, NULL, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
#else
if (gdk_device_grab(keyboard, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)), GDK_OWNERSHIP_WINDOW,
......@@ -863,17 +882,30 @@ static void remmina_connection_holder_check_resize(RemminaConnectionHolder* cnnh
TRACE_CALL("remmina_connection_holder_check_resize");
DECLARE_CNNOBJ
gboolean scroll_required = FALSE;
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay* display;
GdkMonitor* monitor;
#else
GdkScreen* screen;
gint monitor;
#endif
GdkRectangle screen_size;
gint screen_width, screen_height;
gint server_width, server_height;
gint bordersz;
remmina_connection_holder_get_desktop_size(cnnhld, &server_width, &server_height);
#if GTK_CHECK_VERSION(3, 22, 0)
display = gtk_widget_get_display(GTK_WIDGET(cnnhld->cnnwin));
monitor = gdk_display_get_monitor_at_window(display, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)));
#else
screen = gtk_window_get_screen(GTK_WINDOW(cnnhld->cnnwin));
monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(GTK_WIDGET(cnnhld->cnnwin)));
#ifdef gdk_screen_get_monitor_workarea
#endif
#if GTK_CHECK_VERSION(3, 22, 0)
gdk_monitor_get_workarea(monitor, &screen_size);
#elif gdk_screen_get_monitor_workarea
gdk_screen_get_monitor_workarea(screen, monitor, &screen_size);
#else
gdk_screen_get_monitor_geometry(screen, monitor, &screen_size);
......@@ -1137,8 +1169,13 @@ static void remmina_connection_holder_toolbar_fullscreen_option(GtkWidget* widge
g_signal_connect(G_OBJECT(menu), "deactivate", G_CALLBACK(remmina_connection_holder_fullscreen_option_popdown), cnnhld);
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(menu), widget,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, priv->toolitem_fullscreen, 0,
gtk_get_current_event_time());
#endif
}
......@@ -1212,8 +1249,13 @@ static void remmina_connection_holder_toolbar_scaler_option(GtkWidget* widget, R
g_signal_connect(G_OBJECT(menu), "deactivate", G_CALLBACK(remmina_connection_holder_scaler_option_popdown), cnnhld);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, priv->toolitem_fullscreen, 0,
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(menu), widget,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, priv->toolitem_scale, 0,
gtk_get_current_event_time());
#endif
}
static void remmina_connection_holder_switch_page_activate(GtkMenuItem* menuitem, RemminaConnectionHolder* cnnhld)
......@@ -1282,7 +1324,13 @@ static void remmina_connection_holder_toolbar_switch_page(GtkWidget* widget, Rem
g_signal_connect(G_OBJECT(menu), "deactivate", G_CALLBACK(remmina_connection_holder_toolbar_switch_page_popdown),
cnnhld);
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(menu), widget,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, widget, 0, gtk_get_current_event_time());
#endif
}
static void remmina_connection_holder_update_toolbar_autofit_button(RemminaConnectionHolder* cnnhld)
......@@ -1521,7 +1569,13 @@ static void remmina_connection_holder_toolbar_preferences(GtkWidget* widget, Rem
g_signal_connect(G_OBJECT(menu), "deactivate", G_CALLBACK(remmina_connection_holder_toolbar_preferences_popdown),
cnnhld);
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(menu), widget,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, widget, 0, gtk_get_current_event_time());
#endif
}
static void remmina_connection_holder_toolbar_tools(GtkWidget* widget, RemminaConnectionHolder* cnnhld)
......@@ -1613,8 +1667,13 @@ static void remmina_connection_holder_toolbar_tools(GtkWidget* widget, RemminaCo
}
g_strfreev(keystrokes);
}
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(menu), widget,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, remmina_public_popup_position, widget, 0, gtk_get_current_event_time());
#endif
}
static void remmina_connection_holder_toolbar_screenshot(GtkWidget* widget, RemminaConnectionHolder* cnnhld)
......@@ -1818,7 +1877,11 @@ remmina_connection_holder_create_toolbar(RemminaConnectionHolder* cnnhld, gint m
gtk_widget_show(widget);
gtk_container_set_border_width(GTK_CONTAINER(widget), 0);
gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click(GTK_WIDGET(widget), FALSE);
#else
gtk_button_set_focus_on_click(GTK_BUTTON(widget), FALSE);
#endif
if (remmina_pref.small_toolbutton)
{
gtk_widget_set_name(widget, "remmina-small-button");
......@@ -1870,7 +1933,11 @@ remmina_connection_holder_create_toolbar(RemminaConnectionHolder* cnnhld, gint m
gtk_widget_show(widget);
gtk_container_set_border_width(GTK_CONTAINER(widget), 0);
gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click(GTK_WIDGET(widget), FALSE);
#else
gtk_button_set_focus_on_click(GTK_BUTTON(widget), FALSE);
#endif
if (remmina_pref.small_toolbutton)
{
gtk_widget_set_name(widget, "remmina-small-button");
......@@ -2355,7 +2422,11 @@ static void remmina_connection_holder_create_floating_toolbar(RemminaConnectionH
gtk_widget_show(pinbutton);
gtk_box_pack_start(GTK_BOX(hbox), pinbutton, FALSE, FALSE, 0);
gtk_button_set_relief(GTK_BUTTON(pinbutton), GTK_RELIEF_NONE);
#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click(GTK_WIDGET(pinbutton), FALSE);
#else
gtk_button_set_focus_on_click(GTK_BUTTON(pinbutton), FALSE);
#endif
gtk_widget_set_name(pinbutton, "remmina-pin-button");
g_signal_connect(G_OBJECT(pinbutton), "clicked", G_CALLBACK(remmina_connection_holder_toolbar_pin), cnnhld);
priv->pin_button = pinbutton;
......@@ -2612,7 +2683,11 @@ static GtkWidget* remmina_connection_object_create_tab(RemminaConnectionObject*
button = gtk_button_new();
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click(GTK_WIDGET(widget), FALSE);
#else
gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
#endif
gtk_widget_set_name(button, "remmina-small-button");
gtk_widget_show(button);
......@@ -2802,11 +2877,21 @@ remmina_connection_holder_on_notebook_create_window(GtkNotebook* notebook, GtkWi
gint srcpagenum;
GdkWindow* window;
GdkDeviceManager* manager;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice* device = NULL;
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(gdk_display_get_default());
device = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(gdk_display_get_default());
device = gdk_device_manager_get_client_pointer(manager);
#endif
window = gdk_device_get_window_at_position(device, &x, &y);
srccnnwin = REMMINA_CONNECTION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(notebook)));
dstcnnwin = REMMINA_CONNECTION_WINDOW(remmina_widget_pool_find_by_window(REMMINA_TYPE_CONNECTION_WINDOW, window));
......
......@@ -90,7 +90,11 @@ gboolean remmina_external_tools_from_filename(RemminaMain *remminamain, gchar* r
/* Note: event can be NULL here when called from view_onPopupMenu;
* gdk_event_get_time() accepts a NULL argument
*/
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,0,0);
#endif
return TRUE;
}
......
......@@ -710,7 +710,11 @@ static void remmina_ftp_client_popup_menu(RemminaFTPClient *client, GdkEventButt
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(remmina_ftp_client_action_delete), client);
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *)event);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
#endif
}
static gboolean remmina_ftp_client_file_list_on_button_press(GtkWidget *widget, GdkEventButton *event, RemminaFTPClient *client)
......
......@@ -1007,7 +1007,13 @@ gboolean remmina_main_file_list_on_button_press(GtkWidget *widget, GdkEventButto
TRACE_CALL("remmina_main_file_list_on_button_press");
if (event->button == MOUSE_BUTTON_RIGHT)
{
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer(GTK_MENU(remminamain->menu_popup), (GdkEvent *)event);
#else
gtk_menu_popup(remminamain->menu_popup, NULL, NULL, NULL, NULL, event->button, event->time);
#endif
}
return FALSE;
}
......@@ -1018,7 +1024,13 @@ gboolean remmina_main_file_list_on_key_press(GtkWidget *widget, GdkEventKey *eve
TRACE_CALL("remmina_main_file_list_on_key_press");
if (event->keyval == GDK_KEY_Menu)
{
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget(GTK_MENU(remminamain->menu_popup), widget,
GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
(GdkEvent *)event);
#else
gtk_menu_popup(remminamain->menu_popup, NULL, NULL, NULL, NULL, 0, event->time);
#endif
}
return FALSE;
}
......
......@@ -299,7 +299,11 @@ gboolean remmina_protocol_widget_close_connection(RemminaProtocolWidget* gp)
{
TRACE_CALL("remmina_protocol_widget_close_connection");
GdkDisplay *display;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *manager;
#endif
GdkDevice *device = NULL;
gboolean retval;
......@@ -309,11 +313,20 @@ gboolean remmina_protocol_widget_close_connection(RemminaProtocolWidget* gp)
gp->priv->closed = TRUE;
display = gtk_widget_get_display(GTK_WIDGET(gp));
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(display);
device = gdk_seat_get_pointer(seat);
#else
manager = gdk_display_get_device_manager(display);
device = gdk_device_manager_get_client_pointer(manager);
#endif
if (device != NULL)
{
#if GTK_CHECK_VERSION(3, 20, 0)
gdk_seat_ungrab(seat);
#else
gdk_device_ungrab(device, GDK_CURRENT_TIME);
#endif
}
if (gp->priv->chat_window)
......
......@@ -301,6 +301,7 @@ remmina_public_combo_get_active_text(GtkComboBox *combo)
return s;
}
#if !GTK_CHECK_VERSION(3, 22, 0)
void remmina_public_popup_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
{
TRACE_CALL("remmina_public_popup_position");
......@@ -336,6 +337,7 @@ void remmina_public_popup_position(GtkMenu *menu, gint *x, gint *y, gboolean *pu
*y = ty + allocation.height - 1;
*push_in = TRUE;
}
#endif
gchar*
remmina_public_combine_path(const gchar *path1, const gchar *path2)
......
......@@ -80,8 +80,10 @@ void remmina_public_create_group(GtkGrid *table, const gchar *group, gint row, g
gchar* remmina_public_combo_get_active_text(GtkComboBox *combo);
#if !GTK_CHECK_VERSION(3, 22, 0)
/* A function for gtk_menu_popup to get the position right below the widget specified by user_data */
void remmina_public_popup_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
#endif
/* Combine two paths into one by correctly handling trailing slash. Return newly allocated string */
gchar* remmina_public_combine_path(const gchar *path1, const gchar *path2);
......
......@@ -66,7 +66,11 @@ static gboolean remmina_scrolled_viewport_motion_timeout(gpointer data)
RemminaScrolledViewport *gsv;
GtkWidget *child;
GdkDisplay *display;
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat *seat;
#else
GdkDeviceManager *device_manager;
#endif
GdkDevice *pointer;
GdkScreen *screen;
GdkWindow *gsvwin;
......@@ -92,8 +96,13 @@ static gboolean remmina_scrolled_viewport_motion_timeout(gpointer data)
display = gdk_display_get_default();
if (!display)
return FALSE;
#if GTK_CHECK_VERSION(3, 20, 0)
seat = gdk_display_get_default_seat(display);
pointer = gdk_seat_get_pointer(seat);
#else
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
#endif
gdk_device_get_position(pointer, &screen, &x, &y);
w = gdk_window_get_width(gsvwin) + 2; // Add 2px of black scroll border
......
......@@ -410,6 +410,9 @@ remmina_ssh_plugin_popup_menu(GtkWidget *widget, GdkEvent *event, GtkWidget *men
if ((event->type == GDK_BUTTON_PRESS) && (((GdkEventButton*)event)->button == 3)) {
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL);
#else
gtk_menu_popup(GTK_MENU(menu),
NULL,
NULL,
......@@ -417,6 +420,7 @@ remmina_ssh_plugin_popup_menu(GtkWidget *widget, GdkEvent *event, GtkWidget *men
NULL,
((GdkEventButton*)event)->button,
gtk_get_current_event_time());
#endif
return TRUE;
}
......
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