Some documenting thingies.
[irreco.git] / irreco / trunk / src / core / irreco_dlg.c
blob3c6f4ac1a6beb1e66a46b619a9294944c1813ce2
1 /*
2 * irreco - Ir Remote Control
3 * Copyright (C) 2007 Arto Karppinen (arto.karppinen@iki.fi)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "irreco_dlg.h"
22 /**
23 * @addtogroup IrrecoDlg
25 * Base class for Irreco dialogs.
27 * @{ @file
32 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
33 /* Prototypes */
34 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
36 #define IRRECO_DLG_CHILD_DATA_KEY "IrrecoChildDialog"
38 static void irreco_dlg_data_key_cleanup(IrrecoDlg *self, GtkWindow *parent);
42 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
43 /* Construction & Destruction */
44 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
46 /**
47 * @name Construction & Destruction
48 * @{
51 G_DEFINE_TYPE(IrrecoDlg, irreco_dlg, GTK_TYPE_DIALOG)
53 static void irreco_dlg_finalize(GObject *object)
55 G_OBJECT_CLASS(irreco_dlg_parent_class)->finalize(object);
58 static void irreco_dlg_class_init(IrrecoDlgClass *klass)
60 GObjectClass *object_class = G_OBJECT_CLASS(klass);
61 object_class->finalize = irreco_dlg_finalize;
64 static void irreco_dlg_init(IrrecoDlg *self)
66 IRRECO_ENTER
67 IRRECO_RETURN
70 GtkWidget *irreco_dlg_new(void)
72 return g_object_new(IRRECO_TYPE_DLG, NULL);
75 /** @} */
79 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
80 /* Private Functions */
81 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
87 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
88 /* Public Functions */
89 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
91 /**
92 * @name Public Functions
93 * @{
96 void irreco_dlg_set_parent(IrrecoDlg *self, GtkWindow *parent)
98 gint depth = 0;
99 gpointer data;
100 IRRECO_ENTER
102 if (gtk_window_get_transient_for(GTK_WINDOW(self))) {
103 IRRECO_PRINTF("Dialog is already tracient for something.\n");
104 IRRECO_RETURN
107 /* Iterate trough child windows, until we find the one that is
108 topmost on screen. */
109 do {
110 data = g_object_get_data(G_OBJECT(parent),
111 IRRECO_DLG_CHILD_DATA_KEY);
112 if (data != NULL && GTK_IS_WINDOW(data)) {
113 parent = GTK_WINDOW(data);
114 } else {
115 break;
117 depth++;
118 } while (TRUE);
120 IRRECO_PRINTF("Number of parent dialogs on screen: %i\n", depth);
122 /* Set self as a child window. */
123 gtk_window_set_transient_for(GTK_WINDOW(self), parent);
124 g_object_set_data(G_OBJECT(parent), IRRECO_DLG_CHILD_DATA_KEY, self);
126 /* Set up cleanup event. */
127 g_signal_connect(G_OBJECT(self), "destroy",
128 G_CALLBACK(irreco_dlg_data_key_cleanup), parent);
129 IRRECO_RETURN
132 /** @} */
136 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
137 /* Events and Callbacks */
138 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
141 * @name Events and Callbacks
142 * @{
145 static void irreco_dlg_data_key_cleanup(IrrecoDlg *self, GtkWindow *parent)
147 gpointer data;
148 IRRECO_ENTER
150 if (G_IS_OBJECT(parent) == FALSE) IRRECO_RETURN;
152 /* Does parent have a pointer which points to this instace? */
153 data = g_object_get_data(G_OBJECT(parent), IRRECO_DLG_CHILD_DATA_KEY);
154 if (data == NULL || data != self) IRRECO_RETURN;
156 /* Remote the pointer. */
157 g_object_steal_data(G_OBJECT(parent), IRRECO_DLG_CHILD_DATA_KEY);
158 IRRECO_RETURN
161 /** @} */
163 /** @} */