summaryrefslogtreecommitdiff
path: root/src/menu.h
blob: 0e2fcd7762f9d5f7eb842d70ce6341c7fcb679d1 (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
/*      $Id$

        This program 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, or (at your option)
        any later version.

        This program 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 this program; if not, write to the Free Software
        Foundation, Inc., Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA.


        Metacity - (c) 2001 Havoc Pennington
        xfwm4    - (c) 2002-2011 Olivier Fourdan

 */

#ifndef INC_MENU_H
#define INC_MENU_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <X11/Xlib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>

#include "event_filter.h"

typedef enum
{
    MENU_OP_SEPARATOR    = 0,
    MENU_OP_MAXIMIZE     = 1 << 0,
    MENU_OP_UNMAXIMIZE   = 1 << 1,
    MENU_OP_MINIMIZE     = 1 << 2,
    MENU_OP_MINIMIZE_ALL = 1 << 3,
    MENU_OP_UNMINIMIZE   = 1 << 4,
    MENU_OP_MOVE         = 1 << 5,
    MENU_OP_RESIZE       = 1 << 6,
    MENU_OP_SHADE        = 1 << 7,
    MENU_OP_UNSHADE      = 1 << 8,
    MENU_OP_STICK        = 1 << 9,
    MENU_OP_DELETE       = 1 << 10,
    MENU_OP_DESTROY      = 1 << 11,
    MENU_OP_WORKSPACES   = 1 << 12,
    MENU_OP_QUIT         = 1 << 13,
    MENU_OP_RESTART      = 1 << 14,
    MENU_OP_ABOVE        = 1 << 15,
    MENU_OP_BELOW        = 1 << 16,
    MENU_OP_NORMAL       = 1 << 17,
    MENU_OP_FULLSCREEN   = 1 << 18,
    MENU_OP_UNFULLSCREEN = 1 << 19,
    MENU_OP_CONTEXT_HELP = 1 << 20,
    MENU_OP_OTHER        = 1 << 21
}
MenuOp;

typedef enum
{
    MENU_TYPE_SEPARATOR = 0,
    MENU_TYPE_REGULAR,
    MENU_TYPE_RADIO,
    MENU_TYPE_CHECKBOX,
}
MenuType;

typedef struct _Menu Menu;
typedef struct _MenuItem MenuItem;
typedef struct _MenuData MenuData;

typedef void (*MenuFunc) (Menu * menu, MenuOp op, Window xid,
                          gpointer menu_data, gpointer item_data);

struct _MenuItem
{
    MenuOp op;
    MenuType type;
    const char *label;
};

struct _MenuData
{
    Menu *menu;
    MenuOp op;
    gpointer data;
};

struct _Menu
{
    GdkScreen *screen;
    GtkWidget *menu;
    eventFilterSetup *filter_setup;
    MenuFunc func;
    MenuOp ops;
    MenuOp insensitive;
    Window xid;
    gpointer data;
};

Menu                    *menu_default                           (GdkScreen *,
                                                                 Window,
                                                                 MenuOp,
                                                                 MenuOp,
                                                                 MenuFunc,
                                                                 gint,
                                                                 gint,
                                                                 gchar **,
                                                                 gint,
                                                                 eventFilterSetup*,
                                                                 gpointer);
GtkWidget               *menu_item_connect                      (GtkWidget *,
                                                                 MenuData *);
gboolean                 menu_is_opened                         (void);
gboolean                 menu_check_and_close                   (void);
gboolean                 menu_popup                             (Menu *,
                                                                 gint,
                                                                 gint,
                                                                 guint,
                                                                 guint32);
void                     menu_free                              (Menu *);

#endif /* INC_MENU_H */