|
|
|
Gtk+Cairo+transparency | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
// maquetacion.c
//
// Copyright 2011 Leber Schutten <leber@unmerficulworld>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
#include <stdio.h>
#include <gtk/gtk.h>
static gboolean delete_event(GtkWidget *widget,
GdkEvent *event, gpointer data)
{
gtk_main_quit();
return FALSE;
}
gboolean supports_alpha = FALSE;
static gboolean expose(GtkWidget *widget, GdkEventExpose *event, gpointer userdata)
{
cairo_t *cr = gdk_cairo_create(widget->window);
if (supports_alpha)
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1); /* transparent */
else
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* opaque white */
/* draw the background */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_destroy(cr);
return FALSE;
}
static void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer userdata)
{
/* To check if the display supports alpha channels, get the colormap */
GdkScreen *screen = gtk_widget_get_screen(widget);
GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
if (!colormap)
{
printf("Your screen does not support alpha channels!\n");
colormap = gdk_screen_get_rgb_colormap(screen);
supports_alpha = FALSE;
}
else
{
printf("Your screen supports alpha channels!\n");
supports_alpha = TRUE;
}
/* Now we have a colormap appropriate for the screen, use it */
gtk_widget_set_colormap(widget, colormap);
}
static GtkWidget *set_window_attr(GtkWindow *window)
{
char rc_style[512];
gtk_window_set_position(window, GTK_WIN_POS_MOUSE);
gtk_window_set_default_size(window, 300, 200);
gtk_window_set_decorated(window, FALSE);
sprintf(rc_style, "pixmap_path \"/\" \n" "style \"mywindow\" \n" "{\n"
"bg_pixmap[NORMAL]=\"/home/oscar.salvador/c/dl/iconos/%s\"\n"
"}"
"class \"GtkWindow\" style \"mywindow\"\n", "player.png");
gtk_rc_parse_string(rc_style);
gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);
g_signal_connect(window, "expose-event", G_CALLBACK(expose), NULL);
g_signal_connect(window, "screen-changed", G_CALLBACK(screen_changed), NULL);
return GTK_WIDGET(window);
}
void player_intf(void)
{
GtkWidget *window;
const char *p_args[] = { "devicelost" };
int i_args = sizeof(p_args)/sizeof(char *);
char **pp_args = (char **)p_args;
gtk_init (&i_args, &pp_args);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
window = set_window_attr(GTK_WINDOW(window));
screen_changed(window, NULL, NULL);
gtk_widget_show_all(window);
gtk_main();
}
int main(int argc, char **argv)
{
player_intf();
return 0;
}
_______________________________________________ gnome-list mailing list gnome-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gnome-list
[Home] [Fedora Desktop] [Kernel List] [Red Hat Install] [KDE] [Red Hat Watch List] [Red Hat Development] [Red Hat 9 Bible] [Red Hat 9 Mailing List] [Big List of Linux Books] [Gimp] [Yosemite News]
![]() |
![]() |