File: base-window.h

package info (click to toggle)
filemanager-actions 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 27,428 kB
  • sloc: ansic: 48,857; xml: 17,767; sh: 4,662; makefile: 1,375; lisp: 9
file content (261 lines) | stat: -rw-r--r-- 10,317 bytes parent folder | download
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/*
 * FileManager-Actions
 * A file-manager extension which offers configurable context menu actions.
 *
 * Copyright (C) 2005 The GNOME Foundation
 * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
 * Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
 *
 * FileManager-Actions 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.
 *
 * FileManager-Actions 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 FileManager-Actions; see the file COPYING. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Frederic Ruaudel <grumz@grumz.net>
 *   Rodrigo Moya <rodrigo@gnome-db.org>
 *   Pierre Wieser <pwieser@trychlos.org>
 *   ... and many others (see AUTHORS)
 */

#ifndef __UI_BASE_WINDOW_H__
#define __UI_BASE_WINDOW_H__

/**
 * SECTION: base-window
 * @title: BaseWindow
 * @short_description: the BaseWindow base window class definition
 * @include: ui/base-window.h
 *
 * This is a base class which manages a Gtk+ toplevel.
 *
 * One global UI manager is allocated at #BaseWindow class level.
 * Each window may have its own, provided that it is willing to
 * reinstanciate a new builder each time the window is opened.
 *
 *   Cf. http://bugzilla.gnome.org/show_bug.cgi?id=589746 against
 *   Gtk+ 2.16 : a GtkFileChooserWidget embedded in a GtkAssistant is
 *   not displayed when run more than once. As a work-around, reload
 *   the XML ui in a new builder each time we run an assistant !
 *
 * Note that having its own builder implies loading in it the required
 * XML file which holds the needed UI definition, and so even if this
 * same XML file has already been load in the common builder.
 *
 * The common #BaseBuilder is never g_object_unref(), so the
 * embedded Gtk toplevels are only destroyed when quitting the
 * program.
 */

#include <gtk/gtk.h>

G_BEGIN_DECLS

#define BASE_TYPE_WINDOW                ( base_window_get_type())
#define BASE_WINDOW( object )           ( G_TYPE_CHECK_INSTANCE_CAST( object, BASE_TYPE_WINDOW, BaseWindow ))
#define BASE_WINDOW_CLASS( klass )      ( G_TYPE_CHECK_CLASS_CAST( klass, BASE_TYPE_WINDOW, BaseWindowClass ))
#define BASE_IS_WINDOW( object )        ( G_TYPE_CHECK_INSTANCE_TYPE( object, BASE_TYPE_WINDOW ))
#define BASE_IS_WINDOW_CLASS( klass )   ( G_TYPE_CHECK_CLASS_TYPE(( klass ), BASE_TYPE_WINDOW ))
#define BASE_WINDOW_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), BASE_TYPE_WINDOW, BaseWindowClass ))

typedef struct _BaseWindowClassPrivate  BaseWindowClassPrivate;

typedef struct _BaseWindowPrivate       BaseWindowPrivate;

typedef struct {
	/*< private >*/
	GObject                 parent;
	BaseWindowPrivate      *private;
}
	BaseWindow;

/**
 * BaseWindowClass:
 * @initialize_gtk_toplevel: initialize the toplevel GtkWindow (once)
 * @initialize_base_window:  initialize the BaseWindow (each time the
 *                           window is displayed)
 * @all_widgets_showed:      all widgets have been showed
 * @run:                     run the dialog box loop
 *
 * This defines the virtual method a derived class may, should or must implement.
 */
typedef struct {
	/*< private >*/
	GObjectClass            parent;
	BaseWindowClassPrivate *private;

	/*< public >*/
	/**
	 * initialize_gtk_toplevel:
	 * @window: this #BaseWindow instance.
	 * @toplevel: the GtkWindow being initialized.
	 *
	 * This virtual method is invoked after the toplevel GtkWindow has been
	 * allocated and built for the firt time by the GtkBuilder, after all
	 * connected signal handlers have themselves run.
	 *
	 * The derived class should invoke the virtual method of its parent class
	 * at the end of its processing.
	 *
	 * The BaseWindow class ensures that each created instance has its Gtk
	 * toplevel - if it has been successfully loaded - initialized when
	 * returning from instanciation.
	 * The instance has nonetheless still to check if the Gtk toplevel has
	 * actually been built, and to initialize and show it before anything
	 * useful may occur (see base_window_init()).
	 *
	 * Note that initialization process may fall if the XML UI definition cannot
	 * be loaded in memory, or if the required Gtk toplevel cannot be found.
	 * Derived class has so to make sure that a Gtk toplevel actually exists
	 * before continuing. Calling base_window_init() on the instance may
	 * do this check.
	 */
	void ( *initialize_gtk_toplevel )( BaseWindow *window, GtkWindow *toplevel );

	/**
	 * initialize_base_window:
	 * @window: this #BaseWindow instance.
	 *
	 * This virtual method is invoked as the first phase of base_window_init(),
	 * after having checked for the presence of a GtkWindow toplevel, before
	 * actually displaying the widget, and after all connected signal handlers
	 * have themselves run.
	 *
	 * The derived class should invoke the virtual method of its parent class
	 * at the end of its processing.
	 *
	 * The BaseWindow base class implementation of this method, which is
	 * so called last, just does nothing.
	 */
	void ( *initialize_base_window ) ( BaseWindow *window );

	/**
	 * show_widgets:
	 * @window: this #BaseWindow instance.
	 *
	 * This virtual method is invoked at the end of initialization process,
	 * after all connected signal handlers have themselves run.
	 *
	 * The derived class should invoke the virtual method of its parent class
	 * at the end of its processing.
	 *
	 * The BaseWindow base class implementation of this method, which is
	 * so called last, will call gtk_widget_show_all() on the Gtk toplevel.
	 */
	void ( *show_widgets )           ( BaseWindow *window );

	/**
	 * run:
	 * @window: this #BaseWindow instance.
	 * @dialog: the toplevel #GtkWindow.
	 *
	 * Invoked when it is time to run the main loop for the toplevel if
	 * the derived class does not rely on the global main loop.
	 *
	 * The #BaseWindow -derived instance should implement this method if
	 * it wants do something special.
	 *
	 * Returns: the exit code as set by the derived class.
	 */
	int  ( *run )                    ( BaseWindow *window );
}
	BaseWindowClass;

/**
 * Properties defined by the BaseWindow class.
 * They should be provided at object instanciation time.
 *
 * Instanciation time requires:
 * - MAIN_WINDOW
 * - XMLUI_FILENAME
 * - TOPLEVEL_NAME
 * - HAS_OWN_BUILDER
 */
#define BASE_PROP_MAIN_WINDOW					"base-prop-window-main-window"
#define BASE_PROP_XMLUI_FILENAME				"base-prop-window-xmlui-filename"
#define BASE_PROP_HAS_OWN_BUILDER				"base-prop-window-has-own-builder"
#define BASE_PROP_TOPLEVEL_NAME					"base-prop-window-toplevel-name"
#define BASE_PROP_WSP_NAME						"base-prop-window-wsp-name"
#define BASE_PROP_DESTROY_ON_DISPOSE			"base-prop-window-destroy-on-dispose"

/**
 * Signals defined by the BaseWindow class.
 *
 * All signals of this class share the same behavior:
 *
 * - the message is sent to all derived classes, which are free to
 *   connect to the signal in order to implement their own code;
 *
 * - finally, the default class handler invokes the corresponding
 *   virtual method of the derived class. The derived class should
 *   call the parent class method at the end of its implementation.
 *
 * This way, each class is free to choose to implement the action, either
 * as a signal handler or as a virtual method if it is a class derived from
 * BaseWindow.
 *
 * See each signal description for detailed information on exactly
 * when the signal is emitted.
 */
#define BASE_SIGNAL_INITIALIZE_GTK				"base-signal-window-initialize-gtk"
#define BASE_SIGNAL_INITIALIZE_WINDOW			"base-signal-window-initialize-window"
#define BASE_SIGNAL_SHOW_WIDGETS				"base-signal-window-show-widgets"

GType                 base_window_get_type                ( void );

gboolean              base_window_init                    ( BaseWindow *window );
int                   base_window_run                     ( BaseWindow *window );

#ifdef FMA_MAINTAINER_MODE
void                  base_window_dump_children           ( const BaseWindow *window );
#endif

GtkApplication       *base_window_get_application         ( const BaseWindow *window );
GtkApplicationWindow *base_window_get_main_window         ( const BaseWindow *window );
GtkWindow            *base_window_get_gtk_toplevel        ( const BaseWindow *window );
GtkWindow            *base_window_get_gtk_toplevel_by_name( const BaseWindow *window,
																const gchar *name );
GtkWidget            *base_window_get_widget              ( const BaseWindow *window,
																const gchar *name );

void                  base_window_display_error_dlg       ( const BaseWindow *parent,
																const gchar *primary,
																const gchar *secondary );
gboolean              base_window_display_yesno_dlg       ( const BaseWindow *parent,
																const gchar *primary,
																const gchar *secondary );
void                  base_window_display_message_dlg     ( const BaseWindow *parent,
																GSList *message );

gulong                base_window_signal_connect          ( BaseWindow *window,
																GObject *instance,
																const gchar *signal,
																GCallback fn );
gulong                base_window_signal_connect_after    ( BaseWindow *window,
																GObject *instance,
																const gchar *signal,
																GCallback fn );
gulong                base_window_signal_connect_by_name  ( BaseWindow *window,
																const gchar *name,
																const gchar *signal,
																GCallback fn );
gulong                base_window_signal_connect_with_data( BaseWindow *window,
																GObject *instance,
																const gchar *signal,
																GCallback fn,
																void *user_data );
void                  base_window_signal_disconnect       ( BaseWindow *window,
																gulong handler_id );

G_END_DECLS

#endif /* __UI_BASE_WINDOW_H__ */