2014-01-20 17:36:20 -05:00
|
|
|
#ifndef __SIMPLESWITCHER_H__
|
|
|
|
#define __SIMPLESWITCHER_H__
|
2014-01-26 07:29:38 -05:00
|
|
|
#include <X11/X.h>
|
2014-08-07 15:42:16 -04:00
|
|
|
#include <glib.h>
|
2014-01-25 17:37:37 -05:00
|
|
|
|
2014-03-22 16:04:19 -04:00
|
|
|
#define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 )
|
|
|
|
#define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
|
2014-01-20 17:36:20 -05:00
|
|
|
|
2014-01-25 17:37:37 -05:00
|
|
|
extern const char *cache_dir;
|
2014-01-20 17:36:20 -05:00
|
|
|
|
2014-07-21 15:39:24 -04:00
|
|
|
|
2014-06-02 06:54:35 -04:00
|
|
|
/**
|
|
|
|
* Enum used to sum the possible states of ROFI.
|
|
|
|
*/
|
2014-03-22 16:04:19 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
2014-06-02 06:54:35 -04:00
|
|
|
/** Exit. */
|
2014-07-21 15:39:24 -04:00
|
|
|
MODE_EXIT = 1000,
|
2014-06-02 06:54:35 -04:00
|
|
|
/** Skip to the next cycle-able dialog. */
|
2014-07-21 15:39:24 -04:00
|
|
|
NEXT_DIALOG = 1001,
|
|
|
|
/** Reload current DIALOG */
|
|
|
|
RELOAD_DIALOG = 1002
|
2014-01-20 17:36:20 -05:00
|
|
|
} SwitcherMode;
|
|
|
|
|
2014-07-21 15:39:24 -04:00
|
|
|
// switcher callback
|
|
|
|
typedef SwitcherMode ( *switcher_callback )( char **input, void *data );
|
2014-06-02 06:54:35 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* State returned by the rofi window.
|
|
|
|
*/
|
2014-03-22 16:04:19 -04:00
|
|
|
typedef enum
|
|
|
|
{
|
2014-06-02 06:54:35 -04:00
|
|
|
/** Entry is selected. */
|
2014-03-22 16:04:19 -04:00
|
|
|
MENU_OK = 0,
|
2014-06-02 06:54:35 -04:00
|
|
|
/** User canceled the operation. (e.g. pressed escape) */
|
2014-02-01 08:03:23 -05:00
|
|
|
MENU_CANCEL = -1,
|
2014-06-02 06:54:35 -04:00
|
|
|
/** User requested a mode switch */
|
2014-02-01 08:03:23 -05:00
|
|
|
MENU_NEXT = -2,
|
2014-06-02 06:54:35 -04:00
|
|
|
/** Custom (non-matched) input was entered. */
|
2014-02-01 08:03:23 -05:00
|
|
|
MENU_CUSTOM_INPUT = -3,
|
2014-06-02 06:54:35 -04:00
|
|
|
/** User wanted to delete entry from history. */
|
2014-07-21 17:19:45 -04:00
|
|
|
MENU_ENTRY_DELETE = -4,
|
|
|
|
MENU_QUICK_SWITCH = -5,
|
2014-02-01 08:03:23 -05:00
|
|
|
} MenuReturn;
|
2014-01-20 17:36:20 -05:00
|
|
|
|
2014-01-26 06:59:10 -05:00
|
|
|
|
2014-06-02 06:54:35 -04:00
|
|
|
/**
|
|
|
|
* Function prototype for the matching algorithm.
|
|
|
|
*/
|
2014-01-21 04:13:42 -05:00
|
|
|
typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data );
|
2014-06-02 06:54:35 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lines An array of strings to display.
|
2014-07-20 06:29:27 -04:00
|
|
|
* @param num_lines Length of the array with strings to display.
|
2014-06-02 06:54:35 -04:00
|
|
|
* @param input A pointer to a string where the inputted data is placed.
|
|
|
|
* @param prompt The prompt to show.
|
|
|
|
* @param time The current time (used for window interaction.)
|
|
|
|
* @param shift pointer to integer that is set to the state of the shift key.
|
|
|
|
* @param mmc Menu menu match callback, used for matching user input.
|
|
|
|
* @param mmc_data data to pass to mmc.
|
|
|
|
* @param selected_line pointer to integer holding the selected line.
|
|
|
|
*
|
|
|
|
* Main menu callback.
|
|
|
|
*
|
|
|
|
* @returns The command issued (see MenuReturn)
|
|
|
|
*/
|
2014-07-20 06:29:27 -04:00
|
|
|
MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt,
|
2014-03-22 16:04:19 -04:00
|
|
|
Time *time, int *shift,
|
|
|
|
menu_match_cb mmc, void *mmc_data,
|
2014-08-03 11:05:06 -04:00
|
|
|
int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) );
|
2014-01-20 17:36:20 -05:00
|
|
|
|
2014-03-22 16:04:19 -04:00
|
|
|
void catch_exit ( __attribute__( ( unused ) ) int sig );
|
|
|
|
|
|
|
|
typedef enum _WindowLocation
|
|
|
|
{
|
|
|
|
WL_CENTER = 0,
|
|
|
|
WL_NORTH_WEST = 1,
|
|
|
|
WL_NORTH = 2,
|
|
|
|
WL_NORTH_EAST = 3,
|
|
|
|
WL_EAST = 4,
|
|
|
|
WL_EAST_SOUTH = 5,
|
|
|
|
WL_SOUTH = 6,
|
|
|
|
WL_SOUTH_WEST = 7,
|
|
|
|
WL_WEST = 8
|
2014-01-25 18:27:57 -05:00
|
|
|
} WindowLocation;
|
|
|
|
|
2014-01-23 05:39:12 -05:00
|
|
|
/**
|
|
|
|
* Settings
|
|
|
|
*/
|
|
|
|
|
2014-03-22 16:04:19 -04:00
|
|
|
typedef struct _Settings
|
|
|
|
{
|
2014-07-21 15:39:24 -04:00
|
|
|
char *switchers;
|
2014-01-23 05:39:12 -05:00
|
|
|
// Window settings
|
2014-03-22 16:04:19 -04:00
|
|
|
unsigned int window_opacity;
|
2014-01-23 05:39:12 -05:00
|
|
|
// Menu settings
|
2014-03-22 16:04:19 -04:00
|
|
|
unsigned int menu_bw;
|
2014-08-11 14:21:29 -04:00
|
|
|
int menu_width;
|
2014-03-22 16:04:19 -04:00
|
|
|
unsigned int menu_lines;
|
2014-05-19 03:50:09 -04:00
|
|
|
unsigned int menu_columns;
|
2014-03-22 16:04:19 -04:00
|
|
|
char * menu_font;
|
|
|
|
char * menu_fg;
|
|
|
|
char * menu_bg;
|
|
|
|
char * menu_hlfg;
|
|
|
|
char * menu_hlbg;
|
|
|
|
char * menu_bc;
|
2014-01-23 05:39:12 -05:00
|
|
|
// Behavior
|
2014-03-22 16:04:19 -04:00
|
|
|
char * terminal_emulator;
|
2014-09-03 07:07:26 -04:00
|
|
|
char * ssh_client;
|
|
|
|
|
|
|
|
// Command to execute when ssh session is selected.
|
|
|
|
char * ssh_command;
|
|
|
|
// Command for executing an application.
|
|
|
|
char * run_command;
|
|
|
|
char * run_shell_command;
|
2014-05-20 05:22:03 -04:00
|
|
|
|
2014-01-23 05:39:12 -05:00
|
|
|
// Key bindings
|
2014-03-22 16:04:19 -04:00
|
|
|
char * window_key;
|
|
|
|
char * run_key;
|
|
|
|
char * ssh_key;
|
|
|
|
WindowLocation location;
|
2014-05-21 18:38:14 -04:00
|
|
|
unsigned int hmode;
|
2014-03-22 16:04:19 -04:00
|
|
|
unsigned int padding;
|
2014-05-15 10:54:35 -04:00
|
|
|
int y_offset;
|
2014-05-15 15:55:23 -04:00
|
|
|
int x_offset;
|
2014-04-22 05:11:46 -04:00
|
|
|
|
2014-05-17 16:17:07 -04:00
|
|
|
unsigned int fixed_num_lines;
|
2014-06-05 15:55:47 -04:00
|
|
|
|
|
|
|
unsigned int disable_history;
|
2014-07-16 02:42:42 -04:00
|
|
|
|
|
|
|
unsigned int levenshtein_sort;
|
2014-10-19 13:42:02 -04:00
|
|
|
char separator;
|
2014-10-30 12:53:22 -04:00
|
|
|
int element_height;
|
2014-01-23 05:39:12 -05:00
|
|
|
} Settings;
|
|
|
|
|
|
|
|
extern Settings config;
|
2014-02-03 16:49:07 -05:00
|
|
|
|
|
|
|
|
|
|
|
int token_match ( char **tokens, const char *input,
|
2014-03-22 16:04:19 -04:00
|
|
|
__attribute__( ( unused ) ) int index,
|
|
|
|
__attribute__( ( unused ) ) void *data );
|
2014-05-19 15:02:05 -04:00
|
|
|
|
2014-08-27 13:44:15 -04:00
|
|
|
|
|
|
|
void error_dialog ( char *msg );
|
2014-01-20 17:36:20 -05:00
|
|
|
#endif
|