Cleanup GTK_CHECK_VERSION and unify gtk+2/3 code where possible
Replace functions available in gtk+2 and gtk+3 gdk_window_get_* | since 2.24 gtk_widget_get_allocation | since 2.18 gtk_widget_get_window | since 2.14 gtk_window_get_group | since 2.10 gtk_widget_get_mapped | since 2.20 gtk_widget_get_realized | since 2.20 gdk_window_get_display | since 2.24 Remove deprecated GtkNotebookPage and check.
This commit is contained in:
parent
36a55c5f8e
commit
3fc6d6c429
|
@ -679,12 +679,8 @@ is_in_viewport (PlumaWindow *window,
|
|||
gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
|
||||
gdk_window_get_position (gdkwindow, &x, &y);
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
width = gdk_window_get_width(gdkwindow);
|
||||
height = gdk_window_get_height(gdkwindow);
|
||||
#else
|
||||
gdk_drawable_get_size(gdkwindow, &width, &height);
|
||||
#endif
|
||||
|
||||
pluma_utils_get_current_viewport (screen, &vp_x, &vp_y);
|
||||
x += vp_x;
|
||||
|
|
|
@ -522,11 +522,7 @@ menu_position (GtkMenu *menu,
|
|||
|
||||
w = panel->priv->treeview;
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_get_allocation(w, &allocation);
|
||||
#else
|
||||
allocation = w->allocation;
|
||||
#endif
|
||||
|
||||
path = get_current_path (panel);
|
||||
|
||||
|
@ -538,11 +534,7 @@ menu_position (GtkMenu *menu,
|
|||
wx = rect.x;
|
||||
wy = rect.y;
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gdk_window_get_origin (gtk_widget_get_window (w), x, y);
|
||||
#else
|
||||
gdk_window_get_origin (w->window, x, y);
|
||||
#endif
|
||||
|
||||
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
|
||||
|
||||
|
|
|
@ -208,11 +208,7 @@ add_or_remove (PlumaEncodingsComboBox *menu,
|
|||
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
||||
GTK_WINDOW (toplevel));
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
wg = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||
#else
|
||||
wg = GTK_WINDOW (toplevel)->group;
|
||||
#endif
|
||||
if (wg == NULL)
|
||||
{
|
||||
wg = gtk_window_group_new ();
|
||||
|
|
|
@ -259,28 +259,16 @@ find_tab_num_at_pos (PlumaNotebook *notebook,
|
|||
tab = gtk_notebook_get_tab_label (nb, page);
|
||||
g_return_val_if_fail (tab != NULL, AFTER_ALL_TABS);
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
if (!gtk_widget_get_mapped (tab))
|
||||
#else
|
||||
if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab)))
|
||||
#endif
|
||||
{
|
||||
++page_num;
|
||||
continue;
|
||||
}
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)),
|
||||
#else
|
||||
gdk_window_get_origin (GDK_WINDOW (tab->window),
|
||||
#endif
|
||||
&x_root, &y_root);
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_get_allocation(tab, &allocation);
|
||||
#else
|
||||
allocation = tab->allocation;
|
||||
#endif
|
||||
|
||||
max_x = x_root + allocation.x + allocation.width;
|
||||
max_y = y_root + allocation.y + allocation.height;
|
||||
|
|
|
@ -368,11 +368,7 @@ sync_title (PlumaPanel *panel,
|
|||
|
||||
static void
|
||||
notebook_page_changed (GtkNotebook *notebook,
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
GtkWidget *page,
|
||||
#else
|
||||
GtkNotebookPage *page,
|
||||
#endif
|
||||
guint page_num,
|
||||
PlumaPanel *panel)
|
||||
{
|
||||
|
|
|
@ -180,13 +180,8 @@ menu_position_func (GtkMenu *menu,
|
|||
gtk_widget_size_request (gtk_widget_get_toplevel (GTK_WIDGET (menu)), &request);
|
||||
|
||||
/* get the origin... */
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (combo)), x, y);
|
||||
gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
|
||||
#else
|
||||
gdk_window_get_origin (GTK_WIDGET (combo)->window, x, y);
|
||||
allocation = GTK_WIDGET (combo)->allocation;
|
||||
#endif
|
||||
|
||||
/* make the menu as wide as the widget */
|
||||
if (request.width < allocation.width)
|
||||
|
@ -208,11 +203,7 @@ button_press_event (GtkWidget *widget,
|
|||
gint max_height;
|
||||
|
||||
gtk_widget_size_request (combo->priv->menu, &request);
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_get_allocation (GTK_WIDGET (combo), &allocation);
|
||||
#else
|
||||
allocation = GTK_WIDGET (combo)->allocation;
|
||||
#endif
|
||||
|
||||
/* do something relative to our own height here, maybe we can do better */
|
||||
max_height = allocation.height * 20;
|
||||
|
|
|
@ -132,11 +132,7 @@ pluma_utils_menu_position_under_widget (GtkMenu *menu,
|
|||
|
||||
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
#else
|
||||
allocation = widget->allocation;
|
||||
#endif
|
||||
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
|
@ -907,18 +903,10 @@ pluma_utils_get_window_workspace (GtkWindow *gtkwindow)
|
|||
guint ret = PLUMA_ALL_WORKSPACES;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (gtkwindow), 0);
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
g_return_val_if_fail (gtk_widget_get_realized (GTK_WIDGET (gtkwindow)), 0);
|
||||
#else
|
||||
g_return_val_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (gtkwindow)), 0);
|
||||
#endif
|
||||
|
||||
window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
display = gdk_window_get_display (window);
|
||||
#else
|
||||
display = gdk_drawable_get_display (window);
|
||||
#endif
|
||||
|
||||
gdk_error_trap_push ();
|
||||
result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
|
||||
|
|
|
@ -917,11 +917,7 @@ send_focus_change (GtkWidget *widget,
|
|||
g_object_ref (widget);
|
||||
|
||||
fevent->focus_change.type = GDK_FOCUS_CHANGE;
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));
|
||||
#else
|
||||
fevent->focus_change.window = g_object_ref (widget->window);
|
||||
#endif
|
||||
fevent->focus_change.in = in;
|
||||
|
||||
gtk_widget_event (widget, fevent);
|
||||
|
@ -988,11 +984,7 @@ update_search_window_position (PlumaView *view)
|
|||
{
|
||||
gint x, y;
|
||||
gint view_x, view_y;
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
GdkWindow *view_window = gtk_widget_get_window (GTK_WIDGET (view));
|
||||
#else
|
||||
GdkWindow *view_window = GTK_WIDGET (view)->window;
|
||||
#endif
|
||||
|
||||
gtk_widget_realize (view->priv->search_window);
|
||||
|
||||
|
@ -1468,15 +1460,9 @@ ensure_search_window (PlumaView *view)
|
|||
GtkWindowGroup *search_group;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
group = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||
if (view->priv->search_window != NULL)
|
||||
search_group = gtk_window_get_group (GTK_WINDOW (view->priv->search_window));
|
||||
#else
|
||||
group = GTK_WINDOW (toplevel)->group;
|
||||
if (view->priv->search_window != NULL)
|
||||
search_group = GTK_WINDOW (view->priv->search_window)->group;
|
||||
#endif
|
||||
|
||||
if (view->priv->search_window != NULL)
|
||||
{
|
||||
|
@ -1947,11 +1933,7 @@ pluma_view_drag_motion (GtkWidget *widget,
|
|||
if (drag_get_uri_target (widget, context) != GDK_NONE)
|
||||
{
|
||||
gdk_drag_status (context,
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gdk_drag_context_get_suggested_action (context),
|
||||
#else
|
||||
context->suggested_action,
|
||||
#endif
|
||||
timestamp);
|
||||
result = TRUE;
|
||||
}
|
||||
|
@ -2155,11 +2137,7 @@ delete_line (GtkTextView *text_view,
|
|||
|
||||
buffer = gtk_text_view_get_buffer (text_view);
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_text_view_reset_im_context (text_view);
|
||||
#else
|
||||
reset_im_context (text_view);
|
||||
#endif
|
||||
|
||||
/* If there is a selection delete the selected lines and
|
||||
* ignore count */
|
||||
|
|
|
@ -2419,11 +2419,7 @@ language_changed (GObject *object,
|
|||
|
||||
static void
|
||||
notebook_switch_page (GtkNotebook *book,
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
GtkWidget *pg,
|
||||
#else
|
||||
GtkNotebookPage *pg,
|
||||
#endif
|
||||
gint page_num,
|
||||
PlumaWindow *window)
|
||||
{
|
||||
|
@ -3582,11 +3578,7 @@ vpaned_restore_position (GtkWidget *widget,
|
|||
GtkAllocation allocation;
|
||||
gint pos;
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
#else
|
||||
allocation = widget->allocation;
|
||||
#endif
|
||||
|
||||
pluma_debug_message (DEBUG_WINDOW,
|
||||
"Restoring vpaned position: bottom panel size %d",
|
||||
|
|
|
@ -367,11 +367,7 @@ sm_client_xsmp_startup (EggSMClient *client,
|
|||
free (ret_client_id);
|
||||
|
||||
gdk_threads_enter ();
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gdk_x11_set_sm_client_id (xsmp->client_id);
|
||||
#else
|
||||
gdk_set_sm_client_id (xsmp->client_id);
|
||||
#endif
|
||||
gdk_threads_leave ();
|
||||
|
||||
g_debug ("Got client ID \"%s\"", xsmp->client_id);
|
||||
|
|
Loading…
Reference in New Issue