123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- From b2d08e79f8499723ae4dffe8068381dd108898cb Mon Sep 17 00:00:00 2001
- From: galtgendo <galtgendo>
- Date: Sat, 17 Aug 2013 20:55:04 +0200
- Subject: [PATCH] Switch to GTK+ 3
- ---
- configure.ac | 2 +-
- src/preview.c | 180 ++++++++++++++++++++++++++++++++++++----------------------
- 2 files changed, 112 insertions(+), 70 deletions(-)
- diff --git a/configure.ac b/configure.ac
- index b99620f..86df550 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -27,7 +27,7 @@ PKG_CHECK_MODULES(LIBSTARTUPNOTIFICATION, [libstartup-notification-1.0])
- AC_SUBST(LIBSTARTUPNOTIFICATION_CFLAGS)
- AC_SUBST(LIBSTARTUPNOTIFICATION_LIBS)
-
- -PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.24.0])
- +PKG_CHECK_MODULES(GTK, [gtk+-3.0])
- AC_SUBST(GTK_CFLAGS)
- AC_SUBST(GTK_LIBS)
-
- diff --git a/src/preview.c b/src/preview.c
- index f52bb32..c00c3c0 100644
- --- a/src/preview.c
- +++ b/src/preview.c
- @@ -24,6 +24,8 @@
- #include <string.h>
-
- #include <obrender/theme.h>
- +#include <gdk/gdkx.h>
- +#include <cairo-xlib.h>
-
- #define PADDING 2 /* openbox does it :/ */
-
- @@ -53,7 +55,10 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- RrAppearance *selected;
- RrAppearance *bullet; /* for submenu */
-
- - GdkPixmap *pixmap;
- + cairo_surface_t *surface;
- + GdkScreen *screen;
- + Display *xdisplay;
- + Visual *xvisual;
- GdkPixbuf *pixbuf, *tmp_pixbuf;
-
- /* width and height of the whole menu */
- @@ -64,6 +69,10 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- gint bw, bh;
- gint unused;
-
- + screen = gdk_screen_get_default();
- + xdisplay = gdk_x11_get_default_xdisplay();
- + xvisual = gdk_x11_visual_get_xvisual(gdk_screen_get_system_visual(screen));
- +
- /* set up appearances */
- title = theme->a_menu_title;
-
- @@ -126,11 +135,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
-
- theme_pixmap_paint(title_text, bw, title_h);
-
- - pixmap = gdk_pixmap_foreign_new(title_text->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - bw, title_h);
- + surface = cairo_xlib_surface_create(xdisplay, title_text->pixmap,
- + xvisual,
- + bw, title_h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + bw, title_h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, bw, title_h, pixbuf, x, y);
-
- y += title_h + theme->mbwidth;
- @@ -143,11 +154,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
-
- /* draw background for normal entry */
- theme_pixmap_paint(background, bw, bh);
- - pixmap = gdk_pixmap_foreign_new(background->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - bw, bh);
- + surface = cairo_xlib_surface_create(xdisplay, background->pixmap,
- + xvisual,
- + bw, bh);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + bw, bh);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, bw, bh, pixbuf, x, y);
-
- /* draw normal entry */
- @@ -156,11 +169,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- normal->surface.parenty = PADDING;
- RrMinSize(normal, &tw, &th);
- theme_pixmap_paint(normal, tw, th);
- - pixmap = gdk_pixmap_foreign_new(normal->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - tw, th);
- + surface = cairo_xlib_surface_create(xdisplay, normal->pixmap,
- + xvisual,
- + tw, th);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + tw, th);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, tw, th, pixbuf,
- x + PADDING, y + PADDING);
-
- @@ -170,11 +185,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- bullet->surface.parentx = bw - th;
- bullet->surface.parenty = PADDING;
- theme_pixmap_paint(bullet, th, th);
- - pixmap = gdk_pixmap_foreign_new(bullet->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - th, th);
- + surface = cairo_xlib_surface_create(xdisplay, bullet->pixmap,
- + xvisual,
- + th, th);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + th, th);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, th, th, pixbuf,
- width - theme->mbwidth - th, y + PADDING);
-
- @@ -185,11 +202,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- background->surface.parentx = x - theme->mbwidth;
- background->surface.parenty = y - theme->mbwidth;
- theme_pixmap_paint(background, bw, bh);
- - pixmap = gdk_pixmap_foreign_new(background->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - bw, bh);
- + surface = cairo_xlib_surface_create(xdisplay, background->pixmap,
- + xvisual,
- + bw, bh);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + bw, bh);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, bw, bh, pixbuf, x, y);
-
- /* draw disabled entry */
- @@ -198,11 +217,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- disabled->surface.parentx = PADDING;
- disabled->surface.parenty = PADDING;
- theme_pixmap_paint(disabled, tw, th);
- - pixmap = gdk_pixmap_foreign_new(disabled->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - tw, th);
- + surface = cairo_xlib_surface_create(xdisplay, disabled->pixmap,
- + xvisual,
- + tw, th);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + tw, th);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, tw, th, pixbuf,
- x + PADDING, y + PADDING);
-
- @@ -215,11 +236,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- background->surface.parenty = y - theme->mbwidth;
-
- theme_pixmap_paint(background, bw, bh);
- - pixmap = gdk_pixmap_foreign_new(background->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - bw, bh);
- + surface = cairo_xlib_surface_create(xdisplay, background->pixmap,
- + xvisual,
- + bw, bh);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + bw, bh);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, bw, bh, pixbuf, x, y);
-
- /* draw selected entry */
- @@ -228,11 +251,13 @@ static GdkPixbuf* preview_menu(RrTheme *theme)
- selected->surface.parentx = PADDING;
- selected->surface.parenty = PADDING;
- theme_pixmap_paint(selected, tw, th);
- - pixmap = gdk_pixmap_foreign_new(selected->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0,
- - tw, th);
- + surface = cairo_xlib_surface_create(xdisplay, selected->pixmap,
- + xvisual,
- + tw, th);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0,
- + tw, th);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, tw, th, pixbuf,
- x + PADDING, y + PADDING);
- g_object_unref(tmp_pixbuf);
- @@ -247,7 +272,10 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- RrAppearance *handle;
- RrAppearance *a;
-
- - GdkPixmap *pixmap;
- + cairo_surface_t *surface;
- + GdkScreen *screen;
- + Display *xdisplay;
- + Visual *xvisual;
- GdkPixbuf *pixbuf = NULL, *tmp_pixbuf = NULL;
- GdkPixbuf *scratch;
-
- @@ -255,6 +283,10 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
-
- const gchar *layout;
-
- + screen = gdk_screen_get_default();
- + xdisplay = gdk_x11_get_default_xdisplay();
- + xvisual = gdk_x11_visual_get_xvisual(gdk_screen_get_system_visual(screen));
- +
- title = focus ? theme->a_focused_title : theme->a_unfocused_title;
-
- /* set border */
- @@ -271,10 +303,12 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- theme_pixmap_paint(title, w, h);
-
- x = y = theme->fbwidth;
- - pixmap = gdk_pixmap_foreign_new(title->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + surface = cairo_xlib_surface_create(xdisplay, title->pixmap,
- + xvisual,
- + w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
-
- /* calculate label width */
- @@ -317,10 +351,12 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- w = h = theme->button_size + 2;
-
- theme_pixmap_paint(a, w, h);
- - pixmap = gdk_pixmap_foreign_new(a->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + surface = cairo_xlib_surface_create(xdisplay, a->pixmap,
- + xvisual,
- + w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
-
- x += theme->button_size + 2 + theme->paddingx + 1;
- @@ -335,10 +371,12 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- h = theme->label_height;
-
- theme_pixmap_paint(a, w, h);
- - pixmap = gdk_pixmap_foreign_new(a->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + surface = cairo_xlib_surface_create(xdisplay, a->pixmap,
- + xvisual,
- + w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
-
- x += w + theme->paddingx + 1;
- @@ -382,12 +420,14 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- h = theme->button_size;
-
- theme_pixmap_paint(a, w, h);
- - pixmap = gdk_pixmap_foreign_new(a->pixmap);
- + surface = cairo_xlib_surface_create(xdisplay, a->pixmap,
- + xvisual,
- + w, h);
- /* use y + 1 because these buttons should be centered wrt the label
- */
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y + 1);
-
- x += theme->button_size + theme->paddingx + 1;
- @@ -403,10 +443,12 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- h = theme->handle_height;
-
- theme_pixmap_paint(handle, w, h);
- - pixmap = gdk_pixmap_foreign_new(handle->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + surface = cairo_xlib_surface_create(xdisplay, handle->pixmap,
- + xvisual,
- + w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
-
- /* openbox handles this drawing stuff differently (it fills the bottom
- @@ -425,17 +467,17 @@ static GdkPixbuf* preview_window(RrTheme *theme, const gchar *titlelayout,
- w = theme->grip_width;
-
- theme_pixmap_paint(a, w, h);
- - pixmap = gdk_pixmap_foreign_new(a->pixmap);
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + surface = cairo_xlib_surface_create(xdisplay, a->pixmap,
- + xvisual, w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
-
- /* right grip */
- x = width - theme->fbwidth - theme->grip_width;
- - tmp_pixbuf = gdk_pixbuf_get_from_drawable(tmp_pixbuf, pixmap,
- - gdk_colormap_get_system(),
- - 0, 0, 0, 0, w, h);
- + tmp_pixbuf = gdk_pixbuf_get_from_surface(surface,
- + 0, 0, w, h);
- + cairo_surface_destroy(surface);
- gdk_pixbuf_copy_area(tmp_pixbuf, 0, 0, w, h, pixbuf, x, y);
- }
-
- --
- 1.9.1
|