2015-07-29 23:15:08 +00:00
|
|
|
/* Overlay/Transparency
|
2020-09-13 18:59:33 +00:00
|
|
|
* #Keywords: GtkOverlay, GtkSnapshot
|
2011-12-05 23:23:18 +00:00
|
|
|
*
|
2017-10-07 01:58:56 +00:00
|
|
|
* Blur the background behind an overlay.
|
2011-12-05 23:23:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2019-02-22 00:27:41 +00:00
|
|
|
#include "bluroverlay.h"
|
2011-12-05 23:23:18 +00:00
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
do_transparent (GtkWidget *do_widget)
|
|
|
|
{
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
GtkWidget *overlay;
|
2017-10-07 01:58:56 +00:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *label;
|
2019-01-13 04:46:06 +00:00
|
|
|
GtkWidget *picture;
|
2011-12-05 23:23:18 +00:00
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2017-10-31 06:41:15 +00:00
|
|
|
gtk_window_set_display (GTK_WINDOW (window),
|
|
|
|
gtk_widget_get_display (do_widget));
|
2015-06-28 13:23:28 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
|
2020-05-09 16:03:11 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
2011-12-05 23:23:18 +00:00
|
|
|
|
2015-06-20 01:59:15 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Transparency");
|
2011-12-05 23:23:18 +00:00
|
|
|
|
2019-02-22 00:27:41 +00:00
|
|
|
overlay = blur_overlay_new ();
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
2017-10-07 01:58:56 +00:00
|
|
|
|
|
|
|
button = gtk_button_new_with_label ("Don't click this button!");
|
2020-05-02 07:05:19 +00:00
|
|
|
label = gtk_button_get_child (GTK_BUTTON (button));
|
2020-02-26 01:57:20 +00:00
|
|
|
gtk_widget_set_margin_start (label, 50);
|
|
|
|
gtk_widget_set_margin_end (label, 50);
|
|
|
|
gtk_widget_set_margin_top (label, 50);
|
|
|
|
gtk_widget_set_margin_bottom (label, 50);
|
2017-10-07 01:58:56 +00:00
|
|
|
|
|
|
|
gtk_widget_set_opacity (button, 0.7);
|
|
|
|
gtk_widget_set_halign (button, GTK_ALIGN_FILL);
|
|
|
|
gtk_widget_set_valign (button, GTK_ALIGN_START);
|
|
|
|
|
2019-02-22 00:27:41 +00:00
|
|
|
blur_overlay_add_overlay (BLUR_OVERLAY (overlay), button, 5.0);
|
2017-10-07 01:58:56 +00:00
|
|
|
|
|
|
|
button = gtk_button_new_with_label ("Maybe this one?");
|
2020-05-02 07:05:19 +00:00
|
|
|
label = gtk_button_get_child (GTK_BUTTON (button));
|
2020-02-26 01:57:20 +00:00
|
|
|
gtk_widget_set_margin_start (label, 50);
|
|
|
|
gtk_widget_set_margin_end (label, 50);
|
|
|
|
gtk_widget_set_margin_top (label, 50);
|
|
|
|
gtk_widget_set_margin_bottom (label, 50);
|
2017-10-07 01:58:56 +00:00
|
|
|
|
|
|
|
gtk_widget_set_opacity (button, 0.7);
|
|
|
|
gtk_widget_set_halign (button, GTK_ALIGN_FILL);
|
|
|
|
gtk_widget_set_valign (button, GTK_ALIGN_END);
|
|
|
|
|
2019-02-22 00:27:41 +00:00
|
|
|
blur_overlay_add_overlay (BLUR_OVERLAY (overlay), button, 5.0);
|
2011-12-05 23:23:18 +00:00
|
|
|
|
2019-01-13 04:46:06 +00:00
|
|
|
picture = gtk_picture_new_for_resource ("/transparent/portland-rose.jpg");
|
2020-05-03 20:32:33 +00:00
|
|
|
blur_overlay_set_child (BLUR_OVERLAY (overlay), picture);
|
2011-12-05 23:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!gtk_widget_get_visible (window))
|
2015-06-28 13:23:28 +00:00
|
|
|
gtk_widget_show (window);
|
2011-12-05 23:23:18 +00:00
|
|
|
else
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (window));
|
2011-12-05 23:23:18 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|