mirror of
https://github.com/davatorium/rofi.git
synced 2025-01-27 15:25:24 -05:00
consts and small ensurance (though should be correct to begin with)
This commit is contained in:
parent
8c9b72f34e
commit
5bdcd47dde
8 changed files with 38 additions and 32 deletions
|
@ -42,7 +42,7 @@ typedef enum
|
|||
typedef SwitcherMode ( *switcher_callback )( char **input, void *data );
|
||||
typedef void ( *switcher_free )( Switcher *data );
|
||||
|
||||
typedef char * ( *get_display_value )( unsigned int selected_line, struct _Switcher *data, int *state, int get_entry );
|
||||
typedef char * ( *get_display_value )( unsigned int selected_line, const Switcher *data, int *state, int get_entry );
|
||||
/**
|
||||
* State returned by the rofi window.
|
||||
*/
|
||||
|
@ -79,7 +79,7 @@ typedef enum
|
|||
*
|
||||
* @returns 1 when it matches, 0 if not.
|
||||
*/
|
||||
typedef int ( *menu_match_cb )( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *data );
|
||||
typedef int ( *menu_match_cb )( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *data );
|
||||
|
||||
/**
|
||||
* @param sw the Switcher to show.
|
||||
|
@ -297,7 +297,7 @@ struct _Switcher
|
|||
|
||||
get_display_value mgrv;
|
||||
|
||||
int (*is_not_ascii)( struct _Switcher *sw, unsigned int index );
|
||||
int (*is_not_ascii)( const struct _Switcher *sw, unsigned int index );
|
||||
|
||||
// Pointer to private data.
|
||||
void *private_data;
|
||||
|
|
|
@ -174,7 +174,7 @@ static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int se
|
|||
return MODE_EXIT;
|
||||
}
|
||||
static int combi_mode_match ( char **tokens, int not_ascii,
|
||||
int case_sensitive, unsigned int index, Switcher *sw )
|
||||
int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
CombiModePrivateData *pd = sw->private_data;
|
||||
|
||||
|
@ -196,7 +196,7 @@ static int combi_mode_match ( char **tokens, int not_ascii,
|
|||
abort ();
|
||||
return 0;
|
||||
}
|
||||
static char * combi_mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
|
||||
static char * combi_mgrv ( unsigned int selected_line,const Switcher *sw, int *state, int get_entry )
|
||||
{
|
||||
CombiModePrivateData *pd = sw->private_data;
|
||||
if ( !get_entry ) {
|
||||
|
@ -219,7 +219,7 @@ static char * combi_mgrv ( unsigned int selected_line, Switcher *sw, int *state,
|
|||
|
||||
return NULL;
|
||||
}
|
||||
static int combi_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int combi_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
CombiModePrivateData *pd = sw->private_data;
|
||||
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
|
||||
|
|
|
@ -137,7 +137,7 @@ static void parse_ranges ( char *input, struct range_pair **list, unsigned int *
|
|||
}
|
||||
}
|
||||
|
||||
static char *get_display_data ( unsigned int index, Switcher *data, int *state, int get_entry )
|
||||
static char *get_display_data ( unsigned int index, const Switcher *data, int *state, int get_entry )
|
||||
{
|
||||
Switcher *sw = (Switcher *) data;
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) sw->private_data;
|
||||
|
@ -279,13 +279,13 @@ static void dmenu_mode_init ( Switcher *sw )
|
|||
pd->cmd_list = get_dmenu ( &( pd->cmd_list_length ) );
|
||||
}
|
||||
|
||||
static int dmenu_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
|
||||
static int dmenu_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
|
||||
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
|
||||
}
|
||||
|
||||
static int dmenu_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int dmenu_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
|
||||
return is_not_ascii ( rmpd->cmd_list[index] );
|
||||
|
|
|
@ -264,7 +264,7 @@ static void drun_mode_destroy ( Switcher *sw )
|
|||
}
|
||||
}
|
||||
|
||||
static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
|
||||
static char *mgrv ( unsigned int selected_line, const Switcher *sw, int *state, int get_entry )
|
||||
{
|
||||
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
|
||||
*state |= MARKUP;
|
||||
|
@ -290,7 +290,7 @@ static int drun_token_match ( char **tokens,
|
|||
int not_ascii,
|
||||
int case_sensitive,
|
||||
unsigned int index,
|
||||
Switcher *data )
|
||||
const Switcher *data )
|
||||
{
|
||||
DRunModePrivateData *rmpd = (DRunModePrivateData *) data->private_data;
|
||||
if ( rmpd->entry_list[index].name &&
|
||||
|
@ -310,7 +310,7 @@ static unsigned int drun_mode_get_num_entries ( Switcher *sw )
|
|||
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
|
||||
return pd->cmd_list_length;
|
||||
}
|
||||
static int drun_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int drun_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
|
||||
if ( pd->entry_list[index].generic_name ) {
|
||||
|
|
|
@ -327,20 +327,20 @@ static void run_mode_destroy ( Switcher *sw )
|
|||
}
|
||||
}
|
||||
|
||||
static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
{
|
||||
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
|
||||
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
|
||||
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
|
||||
}
|
||||
static int run_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
|
||||
static int run_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
|
||||
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
|
||||
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
|
||||
}
|
||||
|
||||
static int run_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int run_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
|
||||
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
|
||||
return is_not_ascii ( rmpd->cmd_list[index] );
|
||||
}
|
||||
Switcher run_mode =
|
||||
|
|
|
@ -157,19 +157,19 @@ static void script_mode_destroy ( Switcher *sw )
|
|||
sw->private_data = NULL;
|
||||
}
|
||||
}
|
||||
static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
{
|
||||
ScriptModePrivateData *rmpd = sw->private_data;
|
||||
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
|
||||
}
|
||||
|
||||
static int script_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
|
||||
static int script_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
ScriptModePrivateData *rmpd = sw->private_data;
|
||||
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
|
||||
}
|
||||
|
||||
static int script_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int script_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
ScriptModePrivateData *rmpd = sw->private_data;
|
||||
return is_not_ascii ( rmpd->cmd_list[index] );
|
||||
|
|
|
@ -377,18 +377,18 @@ static void ssh_mode_destroy ( Switcher *sw )
|
|||
}
|
||||
}
|
||||
|
||||
static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
|
||||
{
|
||||
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
|
||||
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
|
||||
}
|
||||
static int ssh_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
|
||||
static int ssh_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
|
||||
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
|
||||
}
|
||||
|
||||
static int ssh_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int ssh_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
|
||||
return is_not_ascii ( rmpd->cmd_list[index] );
|
||||
|
|
|
@ -322,12 +322,15 @@ typedef struct _SwitcherModePrivateData
|
|||
|
||||
static int window_match ( char **tokens,
|
||||
__attribute__( ( unused ) ) int not_ascii,
|
||||
int case_sensitive, unsigned int index, Switcher *sw )
|
||||
int case_sensitive, unsigned int index, const Switcher *sw )
|
||||
{
|
||||
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
|
||||
int match = 1;
|
||||
winlist *ids = ( winlist * ) rmpd->ids;
|
||||
client *c = window_client ( display, ids->array[index] );
|
||||
const winlist *ids = ( winlist * ) rmpd->ids;
|
||||
// Want to pull directly out of cache, X calls are not thread safe.
|
||||
int idx = winlist_find ( cache_client, ids->array[index]);
|
||||
g_assert ( idx >= 0 ) ;
|
||||
client *c = cache_client->data[idx];
|
||||
|
||||
if ( tokens ) {
|
||||
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
|
||||
|
@ -557,7 +560,7 @@ static void window_mode_destroy ( Switcher *sw )
|
|||
}
|
||||
}
|
||||
|
||||
static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
|
||||
static char *mgrv ( unsigned int selected_line, const Switcher *sw, int *state, int get_entry )
|
||||
{
|
||||
SwitcherModePrivateData *rmpd = sw->private_data;
|
||||
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
|
||||
|
@ -569,11 +572,14 @@ static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int ge
|
|||
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
|
||||
}
|
||||
|
||||
static int window_is_not_ascii ( Switcher *sw, unsigned int index )
|
||||
static int window_is_not_ascii ( const Switcher *sw, unsigned int index )
|
||||
{
|
||||
SwitcherModePrivateData *rmpd = sw->private_data;
|
||||
winlist *ids = ( winlist * ) rmpd->ids;
|
||||
client *c = window_client ( display, ids->array[index] );
|
||||
const SwitcherModePrivateData *rmpd = sw->private_data;
|
||||
const winlist *ids = ( winlist * ) rmpd->ids;
|
||||
// Want to pull directly out of cache, X calls are not thread safe.
|
||||
int idx = winlist_find ( cache_client, ids->array[index]);
|
||||
g_assert ( idx >= 0 ) ;
|
||||
client *c = cache_client->data[idx];
|
||||
return is_not_ascii ( c->role ) || is_not_ascii ( c->class ) || is_not_ascii ( c->title ) || is_not_ascii ( c->name );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue