00001
#ifndef _MBMENU_H_
00002
#define _MBMENU_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include "libmb/mbconfig.h"
00024
00025
#include <stdio.h>
00026
#include <unistd.h>
00027
#include <stdlib.h>
00028
#include <string.h>
00029
#include <sys/types.h>
00030
#include <sys/stat.h>
00031
#include <dirent.h>
00032
#include <signal.h>
00033
#include <sys/wait.h>
00034
#include <X11/Xlib.h>
00035
#include <X11/Xutil.h>
00036
#include <X11/Xatom.h>
00037
00038
#include <X11/Xresource.h>
00039
#include <X11/extensions/shape.h>
00040
#include <X11/Xatom.h>
00041
#include <X11/keysymdef.h>
00042
#include <X11/keysym.h>
00043
#include <X11/Xmd.h>
00044
00045
#ifdef USE_XSETTINGS
00046
#include <xsettings-client.h>
00047
#endif
00048
00049
#include "mbpixbuf.h"
00050
#include "mbexp.h"
00051
00061
00062
00063
00064
00065
00066
00072 typedef enum {
00073 MBMENU_SET_BG_COL,
00074 MBMENU_SET_FG_COL,
00075 MBMENU_SET_HL_COL,
00076 MBMENU_SET_BD_COL
00077 }
MBMenuColorElement;
00078
00084 typedef enum {
00085 MBMENU_NO_SORT = (1<<1),
00086 MBMENU_PREPEND = (1<<2)
00087 }
MBMenuItemAddFlags;
00088
00089
enum {
00090 MBMENU_ITEM_APP,
00091 MBMENU_ITEM_FOLDER,
00092 MBMENU_ITEM_SEPERATOR
00093 };
00094
00095
00096
#define MBMENU_FG_COL (1<<1)
00097
#define MBMENU_BG_COL (1<<2)
00098
#define MBMENU_HL_COL (1<<3)
00099
#define MBMENU_BD_COL (1<<4)
00100
#define MBMENU_FONT (1<<5)
00101
#define MBMENU_BD_SZ (1<<6)
00102
#define MBMENU_ICON_SZ (1<<7)
00103
#define MBMENU_ICON_FN (1<<8)
00104
#define MBMENU_ICON_FOLDER_FN (1<<9)
00105
#define MBMENU_TRANS (1<<10)
00106
#define MBMENU_BG_FN (1<<11)
00107
#define MBMENU_BEVEL (1<<12)
00108
00109
typedef struct _menu_options
00110 {
00111
char *fontname;
00112
char *foreground_col_spec;
00113
char *background_col_spec;
00114
char *highlight_col_spec;
00115
char *border_col_spec;
00116
int border_size;
00117
int icon_dimention;
00118
char *default_icon_filename;
00119
char *default_folder_icon_filename;
00120
char *bg_img_filename;
00121
int transparency_level;
00122
int bevel_size;
00123
00124 } MBMenuOptions;
00125
00131
typedef struct _menu
00132 {
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
char *title;
00144
struct _menuitem *items;
00145
struct _menuitem *active_item;
00146
struct _menuitem *too_big_start_item;
00147
struct _menuitem *too_big_end_item;
00148
struct _menuitem *parent_item;
00149
00150
int x;
00151
int y;
00152
int width;
00153
int height;
00154
int depth;
00155
00156 Window win;
00157
00158 GC mask_gc;
00159 Bool too_big;
00160
00161
MBDrawable *active_item_drw;
00162
MBDrawable *backing;
00163
00164
00165 }
MBMenuMenu;
00166
00167
00173
typedef struct _menuitem
00174 {
00175
int type;
00176
00177
char *title;
00178 void (* cb)(
struct _menuitem *item );
00179
void *cb_data;
00180
char *info;
00181
char *icon_fn;
00182
00183
MBPixbufImage *img;
00184
00185
MBMenuMenu *child;
00186
struct _menuitem *next_item;
00187
00188
int y;
00189
int h;
00190
00191
00192 }
MBMenuItem;
00193
00199
typedef struct _mbmemu
00200 {
00201 Display *dpy;
00202 Window root;
00203
int screen;
00204
MBFont *font;
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
MBColor *fg_col;
00224
MBColor *bg_col;
00225
MBColor *hl_col;
00226
MBColor *bd_col;
00227
00228
00229 GC gc;
00230
00231 Bool have_highlight_col;
00232
00233
int options;
00234
00235
int border_width;
00236
int inner_border_width;
00237 XColor border_cols[3];
00238
int trans;
00239
00240
int icon_dimention;
00241
00242
MBPixbuf *pb;
00243
MBPixbufImage *img_default_folder;
00244
MBPixbufImage *img_default_app;
00245
MBPixbufImage *img_bg;
00246
00247 Pixmap arrow_icon, arrow_mask;
00248 Pixmap bg_pixmap, bg_pixmap_mask;
00249
00250
struct _menu *rootmenu;
00251 Bool xmenu_is_active;
00252
struct _menu *active[10];
00253
int active_depth;
00254
00255 Atom atom_mbtheme;
00256
00257
struct _menu *keyboard_focus_menu;
00258
00259
#ifdef USE_XSETTINGS
00260
XSettingsClient *xsettings_client;
00261
#endif
00262
00263 }
MBMenu;
00264
00270 typedef void (*
MBMenuActivateCB)(
MBMenuItem *item ) ;
00271
00279
MBMenu *
00280
mb_menu_new(Display *dpy,
int screen);
00281
00289 Bool
00290
mb_menu_set_font (MBMenu *mbmenu,
00291
char *font_desc);
00292
00301 Bool
00302
mb_menu_set_default_icons(MBMenu *mbmenu,
char *folder,
char *app);
00303
00304
00312
void
00313
mb_menu_set_icon_size(MBMenu *mbmenu,
int size);
00314
00322
void
00323
mb_menu_set_col(MBMenu *mbmenu,
00324 MBMenuColorElement element,
00325
char *col_spec);
00326
00334
void
00335
mb_menu_set_trans(MBMenu *mbmenu,
int trans);
00336
00344
MBMenuMenu*
mb_menu_get_root_menu(MBMenu *mbmenu);
00345
00346
00355 Bool
00356
mb_menu_get_root_menu_size(MBMenu *mbmenu,
int *width,
int *height);
00357
00358
00367
void
00368
mb_menu_add_seperator_to_menu(MBMenu *mbmenu,
00369 MBMenuMenu *menu,
00370
int flags);
00371
00382
MBMenuMenu
00383 *
mb_menu_add_path(MBMenu *mbmenu,
00384
char *path,
00385
char *icon_path,
00386
int flags);
00387
00394
void mb_menu_remove_menu(MBMenu *mbmenu,
00395 MBMenuMenu *menu);
00396
00397
00403
void mb_menu_free(MBMenu *mbmenu);
00404
00411 Bool
mb_menu_is_active(MBMenu *mbmenu);
00412
00421
void mb_menu_activate(MBMenu *mbmenu,
00422
int x,
00423
int y);
00424
00430
void mb_menu_deactivate(MBMenu *mbmenu);
00431
00432
00440
void mb_menu_handle_xevent(MBMenu *mbmenu, XEvent *xevent);
00441
00454
MBMenuItem *
00455
mb_menu_new_item (MBMenu *mbmenu,
00456 MBMenuMenu *menu,
00457
char *title,
00458 MBMenuActivateCB activate_callback ,
00459
void *user_data,
00460 MBMenuItemAddFlags flags
00461 );
00462
00463
00464
MBMenuItem *
00465 mb_menu_add_item_to_menu(MBMenu *mbmenu,
00466 MBMenuMenu *menu,
00467
char *title,
00468
char *icon,
00469
char *info,
00470
void (* cmd)( MBMenuItem *item ),
00471
void *cb_data,
00472
int flags);
00473
00481
void
00482
mb_menu_item_icon_set(MBMenu *mbmenu, MBMenuItem *item, MBPixbufImage *img);
00483
00490
void*
00491
mb_menu_item_get_user_data(MBMenuItem *item);
00492
00500
void mb_menu_item_remove(MBMenu *mbmenu, MBMenuMenu *menu, MBMenuItem *item);
00501
00509
void mb_menu_dump(MBMenu *mbmenu, MBMenuMenu *menu);
00510
00511
00514
#endif