[Xfce4-commits] [xfce/xfdesktop] 01/03: Gtk 3.22 is too new
noreply at xfce.org
noreply at xfce.org
Thu Apr 20 17:38:20 CEST 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfdesktop.
commit ec0d9e9f7022ff1145ff27508693baaaec93b9e2
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Thu Apr 20 07:12:01 2017 +0300
Gtk 3.22 is too new
Wrap all the 3.22isms into version checks and drop the Gtk/Gdk
required version back to 3.20.
---
common/xfdesktop-common.c | 11 +++++++++--
common/xfdesktop-common.h | 3 ++-
configure.ac.in | 2 +-
settings/main.c | 23 +++++++++++++++++++++--
src/xfce-workspace.c | 26 ++++++++++++++++++++++++++
src/xfdesktop-icon-view.c | 31 +++++++++++++++++++++++++++++--
6 files changed, 88 insertions(+), 8 deletions(-)
diff --git a/common/xfdesktop-common.c b/common/xfdesktop-common.c
index f3e60d9..a821100 100644
--- a/common/xfdesktop-common.c
+++ b/common/xfdesktop-common.c
@@ -55,17 +55,24 @@
/* Free the string whe done using it */
gchar*
-xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget)
+xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget, gint monitor_num)
{
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkWindow *window = NULL;
GdkDisplay *display = NULL;
GdkMonitor *monitor = NULL;
window = gtk_widget_get_window(widget);
display = gdk_window_get_display(window);
- monitor = gdk_display_get_monitor_at_window(display, window);
+ monitor = gdk_display_get_monitor(display, monitor_num);
return g_strdup(gdk_monitor_get_model(monitor));
+#else
+ GdkScreen *screen = NULL;
+
+ screen = gtk_widget_get_screen(widget);
+ return gdk_screen_get_monitor_plug_name(screen, monitor_num);
+#endif
}
gint
diff --git a/common/xfdesktop-common.h b/common/xfdesktop-common.h
index 7a46089..420f730 100644
--- a/common/xfdesktop-common.h
+++ b/common/xfdesktop-common.h
@@ -89,7 +89,8 @@
G_BEGIN_DECLS
-gchar* xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget);
+gchar* xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget,
+ gint monitor_num);
gint xfdesktop_compare_paths(GFile *a, GFile *b);
diff --git a/configure.ac.in b/configure.ac.in
index 1e3c0ab..1331381 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -14,7 +14,7 @@ m4_define([xfdesktop_version], [xfdesktop_version_major().xfdesktop_version_mino
dnl minimum required versions
m4_define([glib_minimum_version], [2.42.0])
-m4_define([gtk_minimum_version], [3.22.0])
+m4_define([gtk_minimum_version], [3.20.0])
m4_define([libxfce4util_minimum_version], [4.12.0])
m4_define([libxfce4ui_minimum_version], [4.12.0])
m4_define([xfce_minimum_version], [4.12.0])
diff --git a/settings/main.c b/settings/main.c
index 043fc8b..529fc0d 100644
--- a/settings/main.c
+++ b/settings/main.c
@@ -721,7 +721,11 @@ xfdesktop_settings_update_iconview_frame_name(AppearancePanel *panel,
workspace_name = g_strdup(wnck_workspace_get_name(workspace));
+#if GTK_CHECK_VERSION (3, 22, 0)
if(gdk_display_get_n_monitors(gtk_widget_get_display(panel->chk_apply_to_all)) > 1) {
+#else
+ if(gdk_screen_get_n_monitors(gtk_widget_get_screen(panel->chk_apply_to_all)) > 1) {
+#endif
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel->chk_apply_to_all))) {
/* Multi-monitor single workspace */
if(panel->monitor_name) {
@@ -1479,6 +1483,7 @@ suboptions_set_sensitive(GtkToggleButton *btn,
gtk_widget_set_sensitive(box, gtk_toggle_button_get_active(btn));
}
+#if GTK_CHECK_VERSION (3, 22, 0)
static gint
display_get_monitor_num(GdkDisplay *display, GdkMonitor *monitor)
{
@@ -1495,6 +1500,7 @@ display_get_monitor_num(GdkDisplay *display, GdkMonitor *monitor)
g_warning("unable to get the monitor number");
return 0;
}
+#endif
static void
cb_update_background_tab(WnckWindow *wnck_window,
@@ -1506,8 +1512,10 @@ cb_update_background_tab(WnckWindow *wnck_window,
WnckWorkspace *wnck_workspace = NULL;
WnckScreen *wnck_screen = NULL;
GdkWindow *window = NULL;
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display = NULL;
GdkMonitor *monitor = NULL;
+#endif
/* If we haven't found our window return now and wait for that */
if(panel->wnck_window == NULL)
@@ -1520,10 +1528,14 @@ cb_update_background_tab(WnckWindow *wnck_window,
workspace_num = xfdesktop_settings_get_active_workspace(panel, wnck_window);
screen_num = wnck_screen_get_number(wnck_screen);
window = gtk_widget_get_window(panel->image_iconview);
+#if GTK_CHECK_VERSION (3, 22, 0)
display = gdk_window_get_display(window);
monitor = gdk_display_get_monitor_at_window(display, window);
monitor_num = display_get_monitor_num(display, monitor);
- monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview);
+#else
+ monitor_num = gdk_screen_get_monitor_at_window(gtk_widget_get_screen(panel->image_iconview), window);
+#endif
+ monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview, monitor_num);
/* Most of the time we won't change monitor, screen, or workspace so try
* to bail out now if we can */
@@ -1557,7 +1569,7 @@ cb_update_background_tab(WnckWindow *wnck_window,
panel->workspace = workspace_num;
panel->screen = screen_num;
panel->monitor = monitor_num;
- panel->monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview);
+ panel->monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview, monitor_num);
/* The first monitor has the option of doing the "spanning screens" style,
* but only if there's multiple monitors attached. Remove it in all other cases.
@@ -1566,10 +1578,17 @@ cb_update_background_tab(WnckWindow *wnck_window,
*/
gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(panel->image_style_combo),
XFCE_BACKDROP_IMAGE_SPANNING_SCREENS);
+#if GTK_CHECK_VERSION (3, 22, 0)
if(panel->monitor == 0 && gdk_display_get_n_monitors(gtk_widget_get_display(panel->image_style_combo)) > 1) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(panel->image_style_combo),
_("Spanning screens"));
}
+#else
+ if(panel->monitor == 0 && gdk_screen_get_n_monitors(gtk_widget_get_screen(panel->image_iconview)) > 1) {
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(panel->image_style_combo),
+ _("Spanning screens"));
+ }
+#endif
/* connect the new bindings */
xfdesktop_settings_background_tab_change_bindings(panel,
diff --git a/src/xfce-workspace.c b/src/xfce-workspace.c
index c3f9e20..579525e 100644
--- a/src/xfce-workspace.c
+++ b/src/xfce-workspace.c
@@ -144,13 +144,19 @@ xfce_workspace_set_xfconf_property_string(XfceWorkspace *workspace,
{
XfconfChannel *channel = workspace->priv->channel;
char buf[1024];
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display;
+#endif
gchar *monitor_name = NULL;
TRACE("entering");
+#if GTK_CHECK_VERSION (3, 22, 0)
display = gdk_display_manager_get_default_display(gdk_display_manager_get());
monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor_num)));
+#else
+ monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen, monitor_num);
+#endif
/* Get the backdrop's image property */
if(monitor_name == NULL) {
@@ -177,15 +183,21 @@ xfce_workspace_set_xfconf_property_value(XfceWorkspace *workspace,
XfconfChannel *channel = workspace->priv->channel;
char buf[1024];
gchar *monitor_name = NULL;
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display;
+#endif
#ifdef G_ENABLE_DEBUG
gchar *contents = NULL;
#endif
TRACE("entering");
+#if GTK_CHECK_VERSION (3, 22, 0)
display = gdk_display_manager_get_default_display(gdk_display_manager_get());
monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor_num)));
+#else
+ monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen, monitor_num);
+#endif
/* Get the backdrop's image property */
if(monitor_name == NULL) {
@@ -307,7 +319,11 @@ xfce_workspace_monitors_changed(XfceWorkspace *workspace,
/* When spanning screens we only need one backdrop */
n_monitors = 1;
} else {
+#if GTK_CHECK_VERSION (3, 22, 0)
n_monitors = gdk_display_get_n_monitors(gdk_screen_get_display(workspace->priv->gscreen));
+#else
+ n_monitors = gdk_screen_get_n_monitors(workspace->priv->gscreen);
+#endif
}
/* Remove all backdrops so that the correct monitor is added/removed and
@@ -612,13 +628,19 @@ xfce_workspace_connect_backdrop_settings(XfceWorkspace *workspace,
XfconfChannel *channel = workspace->priv->channel;
char buf[1024];
gint pp_len;
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display;
+#endif
gchar *monitor_name = NULL;
TRACE("entering");
+#if GTK_CHECK_VERSION (3, 22, 0)
display = gdk_display_manager_get_default_display(gdk_display_manager_get());
monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor)));
+#else
+ monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen, monitor);
+#endif
if(monitor_name == NULL) {
g_snprintf(buf, sizeof(buf), "%smonitor%d/workspace%d/",
@@ -718,7 +740,11 @@ xfce_workspace_remove_backdrops(XfceWorkspace *workspace)
g_return_if_fail(XFCE_IS_WORKSPACE(workspace));
+#if GTK_CHECK_VERSION (3, 22, 0)
n_monitors = gdk_display_get_n_monitors(gdk_screen_get_display(workspace->priv->gscreen));
+#else
+ n_monitors = gdk_screen_get_n_monitors(workspace->priv->gscreen);
+#endif
for(i = 0; i < n_monitors && i < workspace->priv->nbackdrops; ++i) {
xfce_workspace_disconnect_backdrop_settings(workspace,
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index a504302..655226b 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -2488,21 +2488,37 @@ xfdesktop_rectangle_is_bounded_by(GdkRectangle *rect,
static void
xfdesktop_icon_view_setup_grids_xinerama(XfdesktopIconView *icon_view)
{
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display;
+#else
+ GdkScreen *gscreen;
+#endif
GdkRectangle *monitor_geoms, cell_rect;
gint nmonitors, i, row, col;
DBG("entering");
+#if GTK_CHECK_VERSION (3, 22, 0)
display = gtk_widget_get_display(GTK_WIDGET(icon_view));
-
nmonitors = gdk_display_get_n_monitors(display);
+#else
+ gscreen = gtk_widget_get_screen(GTK_WIDGET(icon_view));
+ nmonitors = gdk_screen_get_n_monitors(gscreen);
+#endif
if(nmonitors == 1) /* optimisation */
return;
monitor_geoms = g_new0(GdkRectangle, nmonitors);
- for(i = 0; i < nmonitors; ++i)
+
+#if GTK_CHECK_VERSION (3, 22, 0)
+ for(i = 0; i < nmonitors; ++i) {
gdk_monitor_get_geometry(gdk_display_get_monitor(display, i), &monitor_geoms[i]);
+ }
+#else
+ for(i = 0; i < nmonitors; ++i) {
+ gdk_screen_get_monitor_geometry(gscreen, i, &monitor_geoms[i]);
+ }
+#endif
/* cubic time; w00t! */
cell_rect.width = cell_rect.height = CELL_SIZE;
@@ -3582,7 +3598,9 @@ xfdesktop_icon_view_add_item_internal(XfdesktopIconView *icon_view,
{
gint16 row, col;
cairo_rectangle_int_t fake_area;
+#if GTK_CHECK_VERSION (3, 22, 0)
GdkDrawingContext *gdc;
+#endif
cairo_region_t *region;
cairo_t *cr;
GdkWindow *gdkwindow;
@@ -3613,14 +3631,23 @@ xfdesktop_icon_view_add_item_internal(XfdesktopIconView *icon_view,
/* Pack it into a cairo region to tell gdk that's where we will be painting */
region = cairo_region_create_rectangle(&fake_area);
+#if GTK_CHECK_VERSION (3, 22, 0)
gdc = gdk_window_begin_draw_frame(gdkwindow, region);
cr = gdk_drawing_context_get_cairo_context(gdc);
+#else
+ cr = gdk_cairo_create(gdkwindow);
+#endif
/* paint the icon */
xfdesktop_icon_view_paint_icon(icon_view, icon, &fake_area, cr);
+#if GTK_CHECK_VERSION (3, 22, 0)
/* we're done drawing */
gdk_window_end_draw_frame(gdkwindow, gdc);
+#else
+ /* we're done drawing */
+ cairo_destroy(cr);
+#endif
cairo_region_destroy(region);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list