This is an automated email from the git hooks/post-receive script. eric pushed a commit to branch master in repository xfce/xfce4-session.
commit 2ce3439456d645cefcb2163a66f22858aebfb2f5 Author: Eric Koegel <[email protected]> Date: Tue Mar 22 20:36:08 2016 +0300 Port engines/balou to cairo --- engines/balou/balou-theme.c | 54 ++++++------ engines/balou/balou-theme.h | 3 +- engines/balou/balou.c | 211 +++++++++++++------------------------------- engines/balou/balou.h | 1 - engines/balou/config.c | 8 +- engines/balou/engine.c | 1 - 6 files changed, 92 insertions(+), 186 deletions(-) diff --git a/engines/balou/balou-theme.c b/engines/balou/balou-theme.c index 708589c..b74542b 100644 --- a/engines/balou/balou-theme.c +++ b/engines/balou/balou-theme.c @@ -199,8 +199,7 @@ balou_theme_get_logo (const BalouTheme *theme, void balou_theme_draw_gradient (const BalouTheme *theme, - GdkDrawable *drawable, - GdkGC *gc, + GdkWindow *root, GdkRectangle logobox, GdkRectangle textbox) { @@ -209,14 +208,19 @@ balou_theme_draw_gradient (const BalouTheme *theme, gint dgreen; gint dblue; gint i; + cairo_t *cr; + + cr = gdk_cairo_create (GDK_DRAWABLE (root)); if (gdk_color_equal (&theme->bgcolor1, &theme->bgcolor2)) { - gdk_gc_set_rgb_fg_color (gc, &theme->bgcolor1); - gdk_draw_rectangle (drawable, gc, TRUE, logobox.x, logobox.y, - logobox.width, logobox.height); - gdk_draw_rectangle (drawable, gc, TRUE, textbox.x, textbox.y, - textbox.width, textbox.height); + gdk_cairo_set_source_color (cr, &theme->bgcolor1); + + gdk_cairo_rectangle (cr, &logobox); + cairo_fill (cr); + + gdk_cairo_rectangle (cr, &textbox); + cairo_fill (cr); } else { @@ -231,18 +235,21 @@ balou_theme_draw_gradient (const BalouTheme *theme, color.green = theme->bgcolor2.green + (i * dgreen / logobox.height); color.blue = theme->bgcolor2.blue + (i * dblue / logobox.height); - gdk_gc_set_rgb_fg_color (gc, &color); - gdk_draw_line (drawable, gc, logobox.x, logobox.y + i, - logobox.x + logobox.width, logobox.y + i); + gdk_cairo_set_source_color (cr, &color); + cairo_move_to(cr, logobox.x, logobox.y + i); + cairo_line_to(cr, logobox.x + logobox.width, logobox.y + i); + cairo_stroke(cr); } if (textbox.width != 0 && textbox.height != 0) { - gdk_gc_set_rgb_fg_color (gc, &theme->bgcolor1); - gdk_draw_rectangle (drawable, gc, TRUE, textbox.x, textbox.y, - textbox.width, textbox.height); + gdk_cairo_set_source_color (cr, &theme->bgcolor1); + gdk_cairo_rectangle (cr, &textbox); + cairo_fill(cr); } } + + cairo_destroy (cr); } @@ -256,11 +263,10 @@ balou_theme_generate_preview (const BalouTheme *theme, GdkRectangle logobox; GdkRectangle textbox; - GdkPixmap *pixmap; GdkPixbuf *pixbuf; GdkPixbuf *scaled; GdkWindow *root; - GdkGC *gc; + cairo_t *cr; gint pw, ph; /* check for a cached preview first */ @@ -286,9 +292,7 @@ balou_theme_generate_preview (const BalouTheme *theme, } root = gdk_screen_get_root_window (gdk_screen_get_default ()); - pixmap = gdk_pixmap_new (GDK_DRAWABLE (root), WIDTH, HEIGHT, -1); - gc = gdk_gc_new (pixmap); - gdk_gc_set_function (gc, GDK_COPY); + cr = gdk_cairo_create(GDK_DRAWABLE(root)); logobox.x = 0; logobox.y = 0; @@ -296,8 +300,7 @@ balou_theme_generate_preview (const BalouTheme *theme, logobox.height = HEIGHT; textbox.x = 0; textbox.y = 0; - balou_theme_draw_gradient (theme, GDK_DRAWABLE (pixmap), - gc, logobox, textbox); + balou_theme_draw_gradient (theme, root, logobox, textbox); pixbuf = balou_theme_get_logo (theme, WIDTH, HEIGHT); if (pixbuf != NULL) @@ -305,20 +308,19 @@ balou_theme_generate_preview (const BalouTheme *theme, pw = gdk_pixbuf_get_width (pixbuf); ph = gdk_pixbuf_get_height (pixbuf); - gdk_draw_pixbuf (GDK_DRAWABLE (pixmap), gc, pixbuf, 0, 0, - (WIDTH - pw) / 2, (HEIGHT - ph) / 2, - pw, ph, GDK_RGB_DITHER_NONE, 0, 0); + gdk_cairo_set_source_pixbuf (cr, pixbuf, (WIDTH - pw) / 2, (HEIGHT - ph) / 2); + cairo_paint (cr); g_object_unref (G_OBJECT (pixbuf)); } - pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (pixmap), + /* replace with gdk_pixbuf_get_from_window in GTK 3 */ + pixbuf = gdk_pixbuf_get_from_drawable (NULL, GDK_DRAWABLE (root), NULL, 0, 0, 0, 0, WIDTH, HEIGHT); scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); g_object_unref (pixbuf); - g_object_unref (pixmap); - g_object_unref (gc); + cairo_destroy(cr); /* store preview */ store_cached_preview (theme, scaled); diff --git a/engines/balou/balou-theme.h b/engines/balou/balou-theme.h index 1e2e1ba..d7bd927 100644 --- a/engines/balou/balou-theme.h +++ b/engines/balou/balou-theme.h @@ -42,8 +42,7 @@ GdkPixbuf *balou_theme_get_logo (const BalouTheme *theme, gint available_width, gint available_height); void balou_theme_draw_gradient (const BalouTheme *theme, - GdkDrawable *drawable, - GdkGC *gc, + GdkWindow *root, GdkRectangle logobox, GdkRectangle textbox); GdkPixbuf *balou_theme_generate_preview (const BalouTheme *theme, diff --git a/engines/balou/balou.c b/engines/balou/balou.c index 752021b..d98eab5 100644 --- a/engines/balou/balou.c +++ b/engines/balou/balou.c @@ -51,10 +51,7 @@ static GdkFilterReturn balou_window_filter (GdkXEvent *xevent, struct _BalouWindow { GdkWindow *window; - GdkPixmap *backbuf; PangoLayout *layout; - GdkGC *gc_copy; - GdkGC *gc_set; GdkRectangle area; GdkRectangle logobox; GdkRectangle textbox; @@ -78,15 +75,11 @@ balou_init (Balou *balou, PangoContext *context; PangoLayout *layout; BalouWindow *window; - GdkColormap *cmap; GdkCursor *cursor; GdkScreen *screen; GdkWindow *root; GdkPixbuf *pb; - GdkGCValues gc_values; - GdkGCValuesMask gc_mask; - GdkGC *gc_copy; - GdkGC *gc_set; + cairo_t *cr; gint layout_height; gint nmonitors; gint nscreens; @@ -97,6 +90,8 @@ balou_init (Balou *balou, gint py; gint pw; gint ph; + gint ww; + gint wh; balou->theme = theme; @@ -124,11 +119,6 @@ balou_init (Balou *balou, nmonitors = gdk_screen_get_n_monitors (screen); root = gdk_screen_get_root_window (screen); - /* allocate fore/background colors */ - cmap = gdk_drawable_get_colormap (root); - gdk_rgb_find_color (cmap, &balou->bgcolor); - gdk_rgb_find_color (cmap, &balou->fgcolor); - /* create pango layout for this screen */ context = gdk_pango_context_get_for_screen (screen); pango_context_set_font_description (context, description); @@ -139,23 +129,11 @@ balou_init (Balou *balou, + 3; pango_font_metrics_unref (metrics); - /* create graphics contexts for this screen */ - gc_mask = GDK_GC_FUNCTION | GDK_GC_EXPOSURES; - gc_values.function = GDK_COPY; - gc_values.graphics_exposures = FALSE; - gc_copy = gdk_gc_new_with_values (root, &gc_values, gc_mask); - gc_mask |= GDK_GC_FOREGROUND | GDK_GC_BACKGROUND; - gc_values.foreground = balou->bgcolor; - gc_values.background = balou->fgcolor; - gc_set = gdk_gc_new_with_values (root, &gc_values, gc_mask); - for (m = 0; m < nmonitors; ++m) { window = balou->windows + i; balou_window_init (window, screen, m, root, cursor); - window->gc_copy = GDK_GC (g_object_ref (gc_copy)); - window->gc_set = GDK_GC (g_object_ref (gc_set)); window->layout = PANGO_LAYOUT (g_object_ref (layout)); /* calculate box dimensions */ @@ -168,13 +146,10 @@ balou_init (Balou *balou, window->textbox.height -= window->logobox.height; balou_theme_draw_gradient (balou->theme, - window->backbuf, - gc_copy, + root, window->logobox, window->textbox); - gdk_gc_set_rgb_fg_color (gc_copy, &balou->fgcolor); - if (mainscreen == screen && mainmonitor == m) balou->mainwin = window; @@ -183,8 +158,6 @@ balou_init (Balou *balou, g_object_unref (context); g_object_unref (layout); - g_object_unref (gc_copy); - g_object_unref (gc_set); } /* show splash windows */ @@ -193,9 +166,8 @@ balou_init (Balou *balou, window = balou->windows + i; gtk_widget_show_now (window->wmwindow); - /*gdk_window_set_back_pixmap (window->wmwindow->window, - window->backbuf, FALSE);*/ - gdk_window_add_filter (window->wmwindow->window, + + gdk_window_add_filter (gtk_widget_get_window (window->wmwindow), balou_window_filter, window); @@ -206,8 +178,18 @@ balou_init (Balou *balou, } gdk_flush (); - /* display logo pixbuf (if any) */ + /* draw the background and display logo pixbuf (if any) */ window = balou->mainwin; + + cr = gdk_cairo_create (GDK_DRAWABLE (window->window)); + + ww = gdk_window_get_width (GDK_WINDOW (window->window)); + wh = gdk_window_get_height (GDK_WINDOW (window->window)); + + gdk_cairo_set_source_color (cr, &balou->bgcolor); + cairo_rectangle (cr, 0, 0, ww, wh); + cairo_fill (cr); + pb = balou_theme_get_logo (balou->theme, window->logobox.width, window->logobox.height); @@ -218,20 +200,13 @@ balou_init (Balou *balou, px = (window->logobox.width - pw) / 2; py = (window->logobox.height - ph) / 2; - gdk_draw_pixbuf (window->backbuf, window->gc_copy, pb, 0, 0, - px, py, pw, ph, GDK_RGB_DITHER_NONE, 0, 0); - gdk_window_clear_area (window->window, px, py, pw, ph); + gdk_cairo_set_source_pixbuf (cr, pb, px, py); + cairo_paint (cr); + g_object_unref (pb); + cairo_destroy (cr); } - /* create fader pixmap */ - balou->fader_pm = gdk_pixmap_new (window->window, - window->textbox.width, - window->textbox.height, - -1); - gdk_draw_rectangle (balou->fader_pm, window->gc_set, TRUE, 0, 0, - window->textbox.width, window->textbox.height); - pango_font_description_free (description); gdk_cursor_unref (cursor); } @@ -242,10 +217,14 @@ balou_fadein (Balou *balou, const gchar *text) { BalouWindow *window = balou->mainwin; GdkRectangle area; + cairo_t *cr; + GdkPixbuf *pb; gint median; gint th; gint tw; gint x; + gint ww; + gint wh; pango_layout_set_text (window->layout, text, -1); pango_layout_get_pixel_size (window->layout, &tw, &th); @@ -255,16 +234,41 @@ balou_fadein (Balou *balou, const gchar *text) area.width = tw + BALOU_INCREMENT; area.height = th; - gdk_draw_rectangle (balou->fader_pm, window->gc_set, TRUE, 0, 0, - window->textbox.width, window->textbox.height); - gdk_draw_layout (balou->fader_pm, window->gc_copy, - BALOU_INCREMENT, 0, window->layout); + ww = gdk_window_get_width (GDK_WINDOW (window->window)); + wh = gdk_window_get_height (GDK_WINDOW (window->window)); + + cr = gdk_cairo_create (GDK_DRAWABLE (window->window)); + + gdk_cairo_set_source_color (cr, &balou->bgcolor); + cairo_rectangle (cr, 0, 0, ww, wh); + cairo_fill (cr); + + pb = balou_theme_get_logo (balou->theme, + window->logobox.width, + window->logobox.height); + if (G_LIKELY (pb != NULL)) + { + gint pw = gdk_pixbuf_get_width (pb); + gint ph = gdk_pixbuf_get_height (pb); + gint px = (window->logobox.width - pw) / 2; + gint py = (window->logobox.height - ph) / 2; + + gdk_cairo_set_source_pixbuf (cr, pb, px, py); + cairo_paint (cr); + + g_object_unref (pb); + } median = (window->area.width - area.width) / 2; for (x = 0; (median - x) > BALOU_INCREMENT; x += BALOU_INCREMENT) { - gdk_draw_drawable (window->window, window->gc_copy, balou->fader_pm, - 0, 0, area.x + x, area.y, area.width, area.height); + gdk_cairo_set_source_color (cr, &balou->bgcolor); + gdk_cairo_rectangle (cr, &window->textbox); + cairo_fill (cr); + + gdk_cairo_set_source_color (cr, &balou->fgcolor); + cairo_move_to (cr, x, window->textbox.y); + pango_cairo_show_layout (cr, window->layout); gdk_flush (); @@ -274,56 +278,10 @@ balou_fadein (Balou *balou, const gchar *text) area.x += median; balou->fader_area = area; - gdk_draw_rectangle (window->backbuf, - window->gc_set, TRUE, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); - - gdk_draw_drawable (window->backbuf, window->gc_copy, balou->fader_pm, - 0, 0, area.x, area.y, area.width, area.height); - - gdk_window_clear_area (window->window, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); + cairo_destroy (cr); } -void -balou_fadeout (Balou *balou) -{ - BalouWindow *window = balou->mainwin; - GdkRectangle area = balou->fader_area; - gint left; - - left = (window->textbox.x + window->textbox.width) - BALOU_INCREMENT; - for (; area.x < left; area.x += BALOU_INCREMENT) - { - gdk_draw_drawable (window->window, window->gc_copy, balou->fader_pm, - 0, 0, area.x, area.y, area.width, area.height); - - gdk_flush (); - - g_main_context_iteration (NULL, FALSE); - } - - gdk_draw_rectangle (window->backbuf, - window->gc_set, TRUE, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); - - gdk_window_clear_area (window->window, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); -} - int balou_run (Balou *balou, @@ -359,9 +317,6 @@ balou_destroy (Balou *balou) for (i = 0; i < balou->nwindows; ++i) balou_window_destroy (balou->windows + i); g_free (balou->windows); - - if (balou->fader_pm != NULL) - g_object_unref (balou->fader_pm); } @@ -399,13 +354,6 @@ balou_window_init (BalouWindow *window, gtk_window_set_screen (GTK_WINDOW (window->wmwindow), screen); gtk_window_set_skip_pager_hint (GTK_WINDOW (window->wmwindow), TRUE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window->wmwindow), TRUE); - - window->backbuf = gdk_pixmap_new (window->window, - window->area.width, - window->area.height, - -1); - - gdk_window_set_back_pixmap (window->window, window->backbuf, FALSE); } @@ -413,58 +361,19 @@ static void balou_window_destroy (BalouWindow *window) { gdk_window_remove_filter (window->window, balou_window_filter, window); - if (GTK_WIDGET_REALIZED (window->wmwindow)) + if (gtk_widget_get_realized (window->wmwindow)) { - gdk_window_remove_filter (window->wmwindow->window, + gdk_window_remove_filter (gtk_widget_get_window(window->wmwindow), balou_window_filter, window); } gdk_window_destroy (window->window); gtk_widget_destroy (window->wmwindow); - g_object_unref (window->backbuf); g_object_unref (window->layout); - g_object_unref (window->gc_copy); - g_object_unref (window->gc_set); } -#if 0 -static void -balou_window_set_text (BalouWindow *window, const gchar *text) -{ - gint text_x; - gint text_y; - gint text_width; - gint text_height; - - pango_layout_set_markup (window->layout, text, -1); - pango_layout_get_pixel_size (window->layout, &text_width, &text_height); - - text_x = (window->textbox.width - text_width) / 2 - + window->textbox.x; - text_y = (window->textbox.height - text_height) / 2 - + window->textbox.y; - - gdk_draw_rectangle (window->backbuf, - window->gc_set, - TRUE, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); - - gdk_draw_layout (window->backbuf, window->gc_copy, - text_x, text_y, window->layout); - - gdk_window_clear_area (window->window, - window->textbox.x, - window->textbox.y, - window->textbox.width, - window->textbox.height); -} -#endif - static GdkFilterReturn balou_window_filter (GdkXEvent *xevent, @@ -492,5 +401,3 @@ balou_window_filter (GdkXEvent *xevent, return GDK_FILTER_CONTINUE; } - - diff --git a/engines/balou/balou.h b/engines/balou/balou.h index 98da07b..16d626d 100644 --- a/engines/balou/balou.h +++ b/engines/balou/balou.h @@ -58,7 +58,6 @@ void balou_init (Balou *balou, BalouTheme *theme); void balou_fadein (Balou *balou, const gchar *text); -void balou_fadeout (Balou *balou); int balou_run (Balou *balou, GtkWidget *dialog); void balou_destroy (Balou *balou); diff --git a/engines/balou/config.c b/engines/balou/config.c index c84094d..f912569 100644 --- a/engines/balou/config.c +++ b/engines/balou/config.c @@ -291,7 +291,7 @@ config_dropped (GtkWidget *treeview, GdkDragContext *context, gboolean succeed = FALSE; GList *fnames; - fnames = gnome_uri_list_extract_filenames ((const gchar *) data->data); + fnames = gnome_uri_list_extract_filenames ((const gchar *) gtk_selection_data_get_data(data)); if (fnames != NULL) { if (g_list_length (fnames) == 1) @@ -722,7 +722,7 @@ config_drag_begin (GtkWidget *treeview, gtk_tree_model_get (model, &iter, NAME_COLUMN, &name, -1); filename = g_strconcat (name, ".tar.gz", NULL); - gdk_property_change (context->source_window, + gdk_property_change (gdk_drag_context_get_source_window(context), gdk_atom_intern ("XdndDirectSave0", FALSE), gdk_atom_intern ("text/plain", FALSE), 8, GDK_PROP_MODE_REPLACE, (const guchar *)filename, strlen (filename)); @@ -756,7 +756,7 @@ config_drag_data_get (GtkWidget *treeview, switch (info) { case TARGET_XDS: - if (gdk_property_get (context->source_window, + if (gdk_property_get (gdk_drag_context_get_source_window(context), gdk_atom_intern ("XdndDirectSave0", FALSE), gdk_atom_intern ("text/plain", FALSE), 0, 1024, FALSE, NULL, NULL, &prop_len, &prop_text) @@ -958,7 +958,7 @@ config_configure (XfsmSplashConfig *config, NULL); ui = config_create (config->rc); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ui, TRUE, TRUE, 6); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (dialog))), ui, TRUE, TRUE, 6); gtk_widget_show_all (ui); gtk_dialog_run (GTK_DIALOG (dialog)); diff --git a/engines/balou/engine.c b/engines/balou/engine.c index 6a18a27..b0304b6 100644 --- a/engines/balou/engine.c +++ b/engines/balou/engine.c @@ -61,7 +61,6 @@ engine_next (XfsmSplashEngine *engine, { Balou *balou = BALOU (engine->user_data); - balou_fadeout (balou); balou_fadein (balou, text); } -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
