summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkdropwindow.c
blob: 3966f1d8bb94148cd3181b76342ee4e49e932b3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

/* OpenIDA - Outil d'analyse de fichiers binaires
 * gtkdropwindow.c - fenêtre de sélection de zone de destination pour dock
 *
 * Copyright (C) 2009 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);

}