diff options
Diffstat (limited to 'src/gtkext/gtkdropwindow.c')
-rw-r--r-- | src/gtkext/gtkdropwindow.c | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/src/gtkext/gtkdropwindow.c b/src/gtkext/gtkdropwindow.c new file mode 100644 index 0000000..b2013f4 --- /dev/null +++ b/src/gtkext/gtkdropwindow.c @@ -0,0 +1,150 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtkdropwindow.c - fenêtre de sélection de zone de destination pour dock + * + * Copyright (C) 2008 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA 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 3 of the License, or + * (at your option) any later version. + * + * OpenIDA 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "gtkdropwindow.h" + + + + + +/* Accompagne le premier affichage de la fenêtre d'affichage. */ +static void gtk_drop_window_realize_cb(GtkDropWindow *, gpointer); + + + + +/* Détermine le type de fenêtre d'affichage pour destination de DnD. */ +G_DEFINE_TYPE(GtkDropWindow, gtk_drop_window, GTK_TYPE_WINDOW) + + + + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Procède à l'initialisation de la fenêtre d'affichage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_drop_window_class_init(GtkDropWindowClass *class) +{ + + +} + + +/****************************************************************************** +* * +* Paramètres : dropwin = composant GTK à initialiser. * +* * +* Description : Procède à l'initialisation de la fenêtre d'affichage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_drop_window_init(GtkDropWindow *dropwin) +{ + gtk_widget_set_size_request(GTK_WIDGET(dropwin), 89, 89); + gtk_window_set_decorated(GTK_WINDOW(dropwin), FALSE); + + g_signal_connect(dropwin, "realize", G_CALLBACK(gtk_drop_window_realize_cb), NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : dropwin = composant GTK à initialiser. * +* data = adresse non utilisée ici. * +* * +* Description : Accompagne le premier affichage de la fenêtre d'affichage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_drop_window_realize_cb(GtkDropWindow *dropwin, gpointer data) +{ + gchar *filename; /* Fichier d'image à charger */ + GdkPixbuf *pixbuf; /* Données de l'image de fond */ + GdkPixmap *pixmap; /* Données de l'image à rendre */ + GdkBitmap *mask; /* Zone utile de l'image */ + GtkStyle *style; /* Apparence de la fenêtre */ + + gdk_window_set_opacity(GTK_WIDGET(dropwin)->window, 0.5); + + filename = find_pixmap_file("dropwin_back.png"); + + if (filename != NULL) + { + pixbuf = gdk_pixbuf_new_from_file(filename, NULL); + + if (GDK_IS_PIXBUF(pixbuf)) + { + gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 1); + + style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dropwin))); + style->bg_pixmap[GTK_STATE_NORMAL] = pixmap; + gtk_widget_set_style(GTK_WIDGET(dropwin), style); + + gdk_window_shape_combine_mask(GTK_WIDGET(dropwin)->window, mask, 0, 0); + + } + + g_free(filename); + + } + + gdk_window_clear(GTK_WIDGET(dropwin)->window); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un nouveau composant pour station dockable. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_drop_window_new(void) +{ + return g_object_new(GTK_TYPE_DROP_WINDOW, NULL); + +} |