Skip to content

Commit

Permalink
Allow building with GTK 3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Jun 19, 2024
1 parent b29776e commit 0fb7713
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 22 deletions.
6 changes: 3 additions & 3 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ if test $USE_GTK2 = yes ; then
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.24)
AC_DEFINE([USE_GTK], [1], [Define if GTK support enabled])
elif test $USE_GTK = yes ; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.22)
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.18)
AC_DEFINE(USE_GTK, 1, [Define if GTK support enabled])
AC_DEFINE(USE_GTK3, 1, [Define if GTK 3 support enabled])
fi
Expand Down Expand Up @@ -232,7 +232,7 @@ AC_ARG_ENABLE(qt5,
if test $USE_QT5 = yes ; then
PKG_CHECK_MODULES([QTCORE], [Qt5Core >= 5.2])
PKG_CHECK_VAR([QTBINPATH], [Qt5Core >= 5.2], [host_bins])
PKG_CHECK_MODULES([QT], [Qt5Core Qt5Gui Qt5Widgets >= 5.2])
PKG_CHECK_MODULES([QT], [Qt5Core Qt5Gui Qt5Widgets Qt5Svg >= 5.2])
AC_DEFINE([USE_QT], [1], [Define if Qt support enabled])
# needed if Qt was built with -reduce-relocations
Expand All @@ -241,7 +241,7 @@ if test $USE_QT5 = yes ; then
elif test $USE_QT = yes ; then
PKG_CHECK_MODULES([QTCORE], [Qt6Core >= 6.0])
PKG_CHECK_VAR([QTBINPATH], [Qt6Core >= 6.0], [libexecdir])
PKG_CHECK_MODULES([QT], [Qt6Core Qt6Gui Qt6Widgets >= 6.0])
PKG_CHECK_MODULES([QT], [Qt6Core Qt6Gui Qt6Widgets Qt6Svg >= 6.0])
AC_DEFINE([USE_QT], [1], [Define if Qt support enabled])
fi
Expand Down
4 changes: 2 additions & 2 deletions src/aosd/aosd_osd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <X11/Xlib.h>
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
Expand Down Expand Up @@ -158,7 +158,7 @@ aosd_osd_create ( void )
/* adjust coordinates and size according to selected monitor */
GdkRectangle rect;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay *display = gdk_screen_get_display( screen );
GdkMonitor *monitor = gdk_display_get_monitor( display, osd_data->cfg_osd->position.multimon_id );
gdk_monitor_get_geometry( monitor, &rect );
Expand Down
2 changes: 1 addition & 1 deletion src/aosd/aosd_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ aosd_ui_configure_position ( aosd_cfg_t * cfg )
GtkWidget *pos_multimon_combobox;
int i = 0;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
int monitors_num = gdk_display_get_n_monitors ( gdk_display_get_default() );
#else
int monitors_num = gdk_screen_get_n_monitors( gdk_screen_get_default() );
Expand Down
2 changes: 1 addition & 1 deletion src/blur_scope/blur_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void BlurScope::draw ()
if (! area || ! gtk_widget_get_window (area))
return;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
GdkWindow * window = gtk_widget_get_window (area);
cairo_region_t * cr_region = cairo_region_create ();

Expand Down
2 changes: 1 addition & 1 deletion src/gtkui/layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static gboolean menu_cb (GtkWidget * widget, GdkEventButton * event)

gtk_widget_show_all (menu);

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer ((GtkMenu *) menu, (const GdkEvent *) event);
#else
gtk_menu_popup ((GtkMenu *) menu, nullptr, nullptr, nullptr, nullptr, event->button, event->time);
Expand Down
6 changes: 3 additions & 3 deletions src/gtkui/ui_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ GtkWindow * get_main_window ()
return (GtkWindow *) window;
}

#ifndef USE_GTK3
#if !GTK_CHECK_VERSION(3, 22, 0)
static void menu_position_cb (GtkMenu *, int * x, int * y, int * push, void * button)
{
GtkAllocation alloc;
Expand All @@ -1060,7 +1060,7 @@ static void menu_button_cb ()
return;
}

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget ((GtkMenu *) menu_main, (GtkWidget *) menu_button,
GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_STATIC, nullptr);
#else
Expand Down Expand Up @@ -1176,7 +1176,7 @@ void show_hide_statusbar ()

static void popup_menu (GtkMenu * menu, const GdkEvent * event)
{
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer (menu, event);
#else
GdkEventButton * button_event = (GdkEventButton *) event;
Expand Down
8 changes: 5 additions & 3 deletions src/gtkui/ui_playlist_notebook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ static GtkWidget * make_close_button (GtkWidget * ebox, Playlist list)

g_signal_connect (button, "clicked", (GCallback) close_button_cb, aud::to_ptr (list));

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click (button, false);
#else
gtk_button_set_focus_on_click ((GtkButton *) button, false);
#endif

#ifdef USE_GTK3
GtkCssProvider * provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"#gtkui-tab-close-button {"
Expand All @@ -155,8 +159,6 @@ static GtkWidget * make_close_button (GtkWidget * ebox, Playlist list)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
#else
gtk_button_set_focus_on_click ((GtkButton *) button, false);

gtk_rc_parse_string (
"style \"gtkui-tab-close-button-style\" {"
" GtkButton::default-border = {0, 0, 0, 0}"
Expand Down
2 changes: 1 addition & 1 deletion src/lyrics-gtk/lyrics-gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static void append_separator_to_menu (GtkWidget * menu)
static void edit_lyrics_cb (GtkMenuItem * menu_item, void * data)
{
const char * edit_uri = (const char *) data;
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_show_uri_on_window (nullptr, edit_uri, GDK_CURRENT_TIME, nullptr);
#else
gtk_show_uri (nullptr, edit_uri, GDK_CURRENT_TIME, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/search-tool/search-tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void list_right_click (void * user, GdkEventButton * event)
GtkWidget * menu = gtk_menu_new ();
audgui_menu_init (menu, {items}, nullptr);

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer ((GtkMenu *) menu, (const GdkEvent *) event);
#else
gtk_menu_popup ((GtkMenu *) menu, nullptr, nullptr, nullptr, nullptr, event->button, event->time);
Expand Down
4 changes: 2 additions & 2 deletions src/skins/dock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void dock_move (int x, int y)
hori = SNAP_DISTANCE + 1;
vert = SNAP_DISTANCE + 1;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay * display = gdk_display_get_default ();
int monitors = gdk_display_get_n_monitors (display);
#else
Expand All @@ -276,7 +276,7 @@ void dock_move (int x, int y)
{
GdkRectangle rect;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gdk_monitor_get_geometry (gdk_display_get_monitor (display, m), & rect);
#else
gdk_screen_get_monitor_geometry (screen, m, & rect);
Expand Down
9 changes: 7 additions & 2 deletions src/skins/menus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ GtkAccelGroup * menu_get_accel_group ()
return accel;
}

#ifndef USE_GTK3
#if !GTK_CHECK_VERSION(3, 22, 0)
typedef struct {
int x, y;
gboolean leftward, upward;
Expand All @@ -300,7 +300,12 @@ static void position_menu (GtkMenu * menu, int * x, int * y, gboolean * push_in,
audgui_get_monitor_geometry (gtk_widget_get_screen ((GtkWidget *) menu), pos->x, pos->y, & geom);

GtkRequisition request;
#ifdef USE_GTK3
gtk_widget_get_preferred_width ((GtkWidget *) menu, NULL, & request.width);
gtk_widget_get_preferred_height ((GtkWidget *) menu, NULL, & request.height);
#else
gtk_widget_size_request ((GtkWidget *) menu, & request);
#endif

if (pos->leftward)
* x = aud::max (pos->x - request.width, geom.x);
Expand All @@ -317,7 +322,7 @@ static void position_menu (GtkMenu * menu, int * x, int * y, gboolean * push_in,
void menu_popup (int id, int x, int y, gboolean leftward, gboolean upward,
const GdkEventButton * event)
{
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer ((GtkMenu *) menus[id], (const GdkEvent *) event);
#else
const MenuPosition pos = {x, y, leftward, upward};
Expand Down
2 changes: 1 addition & 1 deletion src/statusicon/statusicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static gboolean si_cb_tooltip (GtkStatusIcon * icon, int x, int y, gboolean keyb
static void si_menu_show (GtkStatusIcon * icon, GdkEventButton * event)
{
GtkMenu * si_menu = (GtkMenu *) g_object_get_data ((GObject *) icon, "menu");
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer (si_menu, (const GdkEvent *) event);
#else
gtk_menu_popup (si_menu, nullptr, nullptr, nullptr, nullptr, event->button, event->time);
Expand Down
2 changes: 1 addition & 1 deletion src/ui-common/menu-ops-gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void pl_open_folder ()

GError * error = nullptr;

#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_show_uri_on_window (nullptr, folder, GDK_CURRENT_TIME, & error);
#else
gtk_show_uri (gdk_screen_get_default (), folder, GDK_CURRENT_TIME, & error);
Expand Down

0 comments on commit 0fb7713

Please sign in to comment.