1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
3 * Copyright (C) 2006 Armin Burgmeier
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 Library 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
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __CLASSGEN_COMBO_FLAGS_H__
21 #define __CLASSGEN_COMBO_FLAGS_H__
23 #include <gtk/gtktreemodel.h>
24 #include <gtk/gtkhbox.h>
26 #include <glib-object.h>
30 #define CG_TYPE_COMBO_FLAGS (cg_combo_flags_get_type ())
31 #define CG_COMBO_FLAGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CG_TYPE_COMBO_FLAGS, CgComboFlags))
32 #define CG_COMBO_FLAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CG_TYPE_COMBO_FLAGS, CgComboFlagsClass))
33 #define CG_IS_COMBO_FLAGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CG_TYPE_COMBO_FLAGS))
34 #define CG_IS_COMBO_FLAGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CG_TYPE_COMBO_FLAGS))
35 #define CG_COMBO_FLAGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CG_TYPE_COMBO_FLAGS, CgComboFlagsClass))
37 #define CG_TYPE_COMBO_FLAGS_SELECTION_TYPE (cg_combo_flags_selection_type_get_type ())
39 typedef struct _CgComboFlagsClass CgComboFlagsClass
;
40 typedef struct _CgComboFlags CgComboFlags
;
42 /* This widget is a simple hbox that is able to launch a popup window
43 * (similar to a combobox) that may be used to select flags. For each
44 * selected flag, the selected signal is emitted. Flags are selected via
45 * clicking on an entry in the popup or move to it using the up and down
46 * keys and then press space.
48 * The popup may be removed in two different ways. Either by a right mouse
49 * click or the enter key which is interpreted as a successful closure or via
50 * a click somewhere else on the screen or the escape key which is
51 * interpreted as cancellation. cg_combo_flags_editing_canceled may be
52 * used to differentiate between the two.
54 * The widget implements the cell editable interface and may thus be used
55 * from within a cell renderer to edit a cell. Such a cell renderer is
56 * cell-renderer-flags. It should also be possible to use the widget as
57 * a standalone widget if you put something in it (remember, it is a hbox)
58 * that displays the current state, but has not been tested as such. */
60 struct _CgComboFlagsClass
62 GtkHBoxClass parent_class
;
67 GtkHBox parent_instance
;
70 typedef enum _CgComboFlagsSelectionType
72 CG_COMBO_FLAGS_SELECTION_NONE
,
73 CG_COMBO_FLAGS_SELECTION_UNSELECT
,
74 CG_COMBO_FLAGS_SELECTION_SELECT
,
75 CG_COMBO_FLAGS_SELECTION_TOGGLE
76 } CgComboFlagsSelectionType
;
78 GType
cg_combo_flags_selection_type_get_type (void) G_GNUC_CONST
;
79 GType
cg_combo_flags_get_type (void) G_GNUC_CONST
;
81 GtkWidget
*cg_combo_flags_new (void);
82 GtkWidget
*cg_combo_flags_new_with_model (GtkTreeModel
*model
);
83 void cg_combo_flags_popup (CgComboFlags
*combo
);
84 void cg_combo_flags_popdown (CgComboFlags
*combo
);
85 gboolean
cg_combo_flags_editing_canceled (CgComboFlags
*combo
);
89 #endif /* __CLASSGEN_COMBO_FLAGS_H__ */