Skip to content

Commit

Permalink
move to GTK+3(>=3.14), drop GTK+2 code and --with-gtk build option an…
Browse files Browse the repository at this point in the history
…d require libmatekdb and libmate-desktop >= 1.17
  • Loading branch information
handsome-feng committed Jun 12, 2017
1 parent 336d383 commit b553f70
Show file tree
Hide file tree
Showing 30 changed files with 31 additions and 1,317 deletions.
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
NULL =

DISTCHECK_CONFIGURE_FLAGS = \
--without-systemd \
--with-gtk=$(GTK_API_VERSION)
--without-systemd

SUBDIRS = \
src \
Expand Down
37 changes: 8 additions & 29 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,11 @@ GLIB_GSETTINGS

DBUS_REQUIRED_VERSION=0.30
GLIB_REQUIRED_VERSION=2.36.0
GTK_REQUREID_VERSION=3.14.0
X11_REQUIRED_VERSION=1.0
LIBMATE_MENU_REQUIRED_VERSION=1.10.0
MATE_DESKTOP_REQUIRED_VERSION=1.9.4
LIBMATEKBDUI_REQUIRED_VERSION=1.7.1

AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 2.0)])],
[case "$with_gtk" in
2.0|3.0) ;;
*) AC_MSG_ERROR([invalid gtk version specified]) ;;
esac],
[with_gtk=2.0])
AC_MSG_RESULT([$with_gtk])

case "$with_gtk" in
2.0) GTK_API_VERSION=2.0
GTK_REQUIRED_VERSION=2.24.0
;;
3.0) GTK_API_VERSION=3.0
GTK_REQUIRED_VERSION=3.0.0
;;
esac

AC_SUBST(GTK_API_VERSION)
MATE_DESKTOP_REQUIRED_VERSION=1.17.0
LIBMATEKBDUI_REQUIRED_VERSION=1.17.0

AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(crypt.h sys/select.h)
Expand All @@ -88,7 +68,7 @@ AC_CHECK_FUNCS([setresuid setenv unsetenv clearenv])
PKG_CHECK_MODULES(UKUI_SCREENSAVER,
x11 >= $X11_REQUIRED_VERSION
xscrnsaver
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
dbus-glib-1 >= $DBUS_REQUIRED_VERSION
gio-2.0 >= $GLIB_REQUIRED_VERSION
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED_VERSION
Expand All @@ -99,14 +79,14 @@ AC_SUBST(UKUI_SCREENSAVER_LIBS)
PKG_CHECK_MODULES(UKUI_SCREENSAVER_DIALOG,
gio-2.0 >= $GLIB_REQUIRED_VERSION
gthread-2.0
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED_VERSION)
AC_SUBST(UKUI_SCREENSAVER_DIALOG_CFLAGS)
AC_SUBST(UKUI_SCREENSAVER_DIALOG_LIBS)

PKG_CHECK_MODULES(UKUI_SCREENSAVER_CAPPLET,
gio-2.0 >= $GLIB_REQUIRED_VERSION
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION
gtk+-3.0 >= $GTK_REQUIRED_VERSION
mate-desktop-2.0 >= $MATE_DESKTOP_REQUIRED_VERSION
libmate-menu >= $LIBMATE_MENU_REQUIRED_VERSION)
AC_SUBST(UKUI_SCREENSAVER_CAPPLET_CFLAGS)
Expand Down Expand Up @@ -137,7 +117,7 @@ esac

# Optional dependencies for the theme engines

SAVER_MODULES="gthread-2.0 gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION gobject-2.0 >= $GLIB_REQUIRED_VERSION"
SAVER_MODULES="gthread-2.0 gtk+-3.0 >= $GTK_REQUIRED_VERSION gobject-2.0 >= $GLIB_REQUIRED_VERSION"

PKG_CHECK_MODULES(UKUI_SCREENSAVER_SAVER, $SAVER_MODULES)
AC_SUBST(UKUI_SCREENSAVER_SAVER_CFLAGS)
Expand Down Expand Up @@ -167,7 +147,7 @@ AC_SUBST(PAM_PREFIX)
# Desktop entry handling

PKG_CHECK_MODULES(LIB_MATE_MENU,
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION)
gtk+-3.0 >= $GTK_REQUIRED_VERSION)

AC_SUBST(LIB_MATE_MENU_CFLAGS)
AC_SUBST(LIB_MATE_MENU_LIBS)
Expand Down Expand Up @@ -1140,7 +1120,6 @@ echo "
Docs enabled: ${enable_docbook_docs}

GL: ${have_libgl}
GTK+ API version: ${GTK_API_VERSION}

Screen locking enabled: ${enable_locking}
Show keyboard indicator: ${with_kbd_layout_indicator}
Expand Down
68 changes: 0 additions & 68 deletions savers/floaters.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include <glib/gi18n.h>

#include <gdk/gdk.h>
#include <gdk/gdkx.h>

#include <gtk/gtk.h>

#include "gs-theme-window.h"
Expand Down Expand Up @@ -284,13 +282,8 @@ static void screen_saver_create_floaters (ScreenSaver *screen_saver);
static void screen_saver_destroy_floaters (ScreenSaver *screen_saver);
static void screen_saver_on_size_allocate (ScreenSaver *screen_saver,
GtkAllocation *allocation);
#if GTK_CHECK_VERSION (3, 0, 0)
static void screen_saver_on_draw (ScreenSaver *screen_saver,
cairo_t *context);
#else
static void screen_saver_on_expose_event (ScreenSaver *screen_saver,
GdkEventExpose *event);
#endif
static gboolean do_print_screen_saver_stats (ScreenSaver *screen_saver);
static GdkPixbuf *gamma_correct (const GdkPixbuf *input_pixbuf);

Expand Down Expand Up @@ -860,15 +853,9 @@ screen_saver_new (GtkWidget *drawing_area,
G_CALLBACK (screen_saver_on_size_allocate),
screen_saver);

#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect_swapped (G_OBJECT (drawing_area), "draw",
G_CALLBACK (screen_saver_on_draw),
screen_saver);
#else
g_signal_connect_swapped (G_OBJECT (drawing_area), "expose-event",
G_CALLBACK (screen_saver_on_expose_event),
screen_saver);
#endif

screen_saver->first_update_time = 0.0;
screen_saver->current_calculated_stats_time = 0.0;
Expand Down Expand Up @@ -1021,70 +1008,30 @@ compare_floaters (ScreenSaverFloater *a,
}

static void
#if GTK_CHECK_VERSION (3, 0, 0)
screen_saver_on_draw (ScreenSaver *screen_saver,
cairo_t *context)
#else
screen_saver_on_expose_event (ScreenSaver *screen_saver,
GdkEventExpose *event)
#endif
{
GList *tmp;
#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *context;
#endif

if (screen_saver->floaters == NULL)
screen_saver_create_floaters (screen_saver);

#if !GTK_CHECK_VERSION (3, 0, 0)
context = gdk_cairo_create (gtk_widget_get_window (screen_saver->drawing_area));

cairo_rectangle (context,
(double) event->area.x,
(double) event->area.y,
(double) event->area.width,
(double) event->area.height);
cairo_clip (context);
#endif

screen_saver->floaters = g_list_sort (screen_saver->floaters,
(GCompareFunc)compare_floaters);

for (tmp = screen_saver->floaters; tmp != NULL; tmp = tmp->next)
{
ScreenSaverFloater *floater;
#if !GTK_CHECK_VERSION (3, 0, 0)
GdkRectangle rect;
gint size;
#endif

floater = (ScreenSaverFloater *) tmp->data;

#if !GTK_CHECK_VERSION (3, 0, 0)
size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale),
FLOATER_MIN_SIZE, FLOATER_MAX_SIZE);

rect.x = (int) (floater->position.x - .5 * G_SQRT2 * size);
rect.y = (int) (floater->position.y - .5 * G_SQRT2 * size);
rect.width = G_SQRT2 * size;
rect.height = G_SQRT2 * size;

if (!gdk_region_rect_in (event->region, &rect))
continue;
#endif

if (!screen_saver_floater_do_draw (screen_saver, floater, context))
{
gtk_main_quit ();
break;
}
}

#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (context);
#endif

screen_saver->draw_ops_pending = TRUE;
screen_saver->frame_count++;
}
Expand Down Expand Up @@ -1219,11 +1166,6 @@ main (int argc,
ScreenSaver *screen_saver;
GtkWidget *window;
GtkWidget *drawing_area;
#if !GTK_CHECK_VERSION (3, 0, 0)
GtkStyle *style;
GtkStateType state;
GdkColor black = { 0, 0x0000, 0x0000, 0x0000 };
#endif

GError *error;

Expand Down Expand Up @@ -1264,16 +1206,6 @@ main (int argc,

drawing_area = GTK_WIDGET (gtk_drawing_area_new ());

#if !GTK_CHECK_VERSION (3, 0, 0)
style = gtk_widget_get_style (drawing_area);
state = (GtkStateType) 0;
while (state < (GtkStateType) G_N_ELEMENTS (style->bg))
{
gtk_widget_modify_bg (drawing_area, state, &black);
state++;
}
#endif

gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);

Expand Down
27 changes: 0 additions & 27 deletions savers/gs-theme-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,8 @@ gs_theme_engine_get_property (GObject *object,
static void
gs_theme_engine_clear (GtkWidget *widget)
{
#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color = { 0.0, 0.0, 0.0, 1.0 };
GtkStateFlags state;
#else
GdkColor color = { 0, 0x0000, 0x0000, 0x0000 };
GdkColormap *colormap;
GtkStyle *style;
GtkStateType state;
#endif

g_return_if_fail (GS_IS_THEME_ENGINE (widget));

Expand All @@ -127,24 +120,9 @@ gs_theme_engine_clear (GtkWidget *widget)
return;
}

#if GTK_CHECK_VERSION (3, 0, 0)
state = gtk_widget_get_state_flags (widget);
gtk_widget_override_background_color (widget, state, &color);
gdk_window_set_background_rgba (gtk_widget_get_window (widget), &color);
#else
style = gtk_widget_get_style (widget);
state = (GtkStateType) 0;
while (state < (GtkStateType) G_N_ELEMENTS (style->bg))
{
gtk_widget_modify_bg (widget, state, &color);
state++;
}

colormap = gdk_drawable_get_colormap (gtk_widget_get_window (widget));
gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE);
gdk_window_set_background (gtk_widget_get_window (widget), &color);
gdk_window_clear (gtk_widget_get_window (widget));
#endif
gdk_flush ();
}

Expand Down Expand Up @@ -222,12 +200,7 @@ gs_theme_engine_get_window_size (GSThemeEngine *engine,
NULL,
NULL,
width,
#if !GTK_CHECK_VERSION (3, 0, 0)
height,
NULL);
#else
height);
#endif
}

GdkWindow *
Expand Down
54 changes: 0 additions & 54 deletions savers/gs-theme-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,10 @@ gs_theme_window_class_init (GSThemeWindowClass *klass)
widget_class->realize = gs_theme_window_real_realize;
}

#if !GTK_CHECK_VERSION (3, 0, 0)
static void
force_no_pixmap_background (GtkWidget *widget)
{
static gboolean first_time = TRUE;

if (first_time)
{
gtk_rc_parse_string ("\n"
" style \"gs-theme-engine-style\"\n"
" {\n"
" bg_pixmap[NORMAL] = \"<none>\"\n"
" bg_pixmap[ACTIVE] = \"<none>\"\n"
" bg_pixmap[PRELIGHT] = \"<none>\"\n"
" bg_pixmap[SELECTED] = \"<none>\"\n"
" bg_pixmap[INSENSITIVE] = \"<none>\"\n"
" bg[NORMAL] = \"#000000\"\n"
" bg[ACTIVE] = \"#000000\"\n"
" bg[PRELIGHT] = \"#000000\"\n"
" bg[SELECTED] = \"#000000\"\n"
" bg[INSENSITIVE] = \"#000000\"\n"
" }\n"
" widget \"gs-window*\" style : highest \"gs-theme-engine-style\"\n"
"\n");
first_time = FALSE;
}

gtk_widget_set_name (widget, "gs-window");
}
#endif

static void
gs_theme_window_init (GSThemeWindow *window)
{
#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
#else
force_no_pixmap_background (GTK_WIDGET (window));
#endif
}

static void
Expand Down Expand Up @@ -144,12 +109,7 @@ gs_theme_window_real_realize (GtkWidget *widget)
((*end == ' ') || (*end == '\0')) &&
((remote_xwindow < G_MAXULONG) || (errno != ERANGE)))
{
#if GTK_CHECK_VERSION (3, 0, 0)
window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow);
#else
window = gdk_window_foreign_new (remote_xwindow);
#endif

if (window != NULL)
{
/* This is a kludge; we need to set the same
Expand Down Expand Up @@ -183,38 +143,24 @@ gs_theme_window_real_realize (GtkWidget *widget)
return;
}

#if GTK_CHECK_VERSION (3, 0, 0)
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
window);
#else
gtk_style_set_background (gtk_widget_get_style (widget),
window,
GTK_STATE_NORMAL);
#endif
gdk_window_set_decorations (window, (GdkWMDecoration) 0);
gdk_window_set_events (window, gdk_window_get_events (window) | event_mask);

gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
gtk_widget_set_realized (widget, TRUE);

#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_get_geometry (window, &x, &y, &width, &height);
#else
gdk_window_get_geometry (window, &x, &y, &width, &height, NULL);
#endif

if (width < MIN_SIZE || height < MIN_SIZE)
{
g_critical ("This window is way too small to use");
exit (1);
}

#if GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_get_preferred_size (widget, &requisition, NULL);
#else
gtk_widget_size_request (widget, &requisition);
#endif
allocation.x = x;
allocation.y = y;
allocation.width = width;
Expand Down
Loading

0 comments on commit b553f70

Please sign in to comment.