mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Constness.
This commit is contained in:
parent
ad53de507c
commit
ef3c773097
9 changed files with 57 additions and 50 deletions
|
@ -75,6 +75,7 @@ AC_CHECK_FUNC([strtok_r],, AC_MSG_ERROR("Could not find strtok_r"))
|
|||
AC_CHECK_FUNC([flock],, AC_MSG_ERROR("Could not find flock"))
|
||||
AC_CHECK_FUNC([ftruncate],,AC_MSG_ERROR("Could not find ftruncate"))
|
||||
AC_CHECK_FUNC([fcntl],, AC_MSG_ERROR("Could not find fcntl"))
|
||||
AC_CHECK_FUNC([setlocale],,AC_MSG_ERROR("Could not find setlocale"))
|
||||
|
||||
dnl ---------------------------------------------------------------------
|
||||
dnl Check dependencies
|
||||
|
|
|
@ -85,6 +85,7 @@ int find_arg_str ( const char * const key, char** val );
|
|||
*/
|
||||
int find_arg ( const char * const key );
|
||||
|
||||
|
||||
/**
|
||||
* @param tokens List of (input) tokens to match.
|
||||
* @param input The entry to match against.
|
||||
|
@ -93,8 +94,7 @@ int find_arg ( const char * const key );
|
|||
*
|
||||
* @returns TRUE when matches, FALSE otherwise
|
||||
*/
|
||||
int token_match ( GRegex **tokens, const char *input );
|
||||
|
||||
int token_match ( GRegex * const *tokens, const char *input );
|
||||
/**
|
||||
* @param cmd The command to execute.
|
||||
*
|
||||
|
|
|
@ -77,7 +77,7 @@ void scrollbar_draw ( scrollbar *sb, cairo_t *draw );
|
|||
*
|
||||
* Calculate the position of the click relative to the max value of bar
|
||||
*/
|
||||
unsigned int scrollbar_clicked ( scrollbar *sb, int y );
|
||||
unsigned int scrollbar_clicked ( const scrollbar *sb, int y );
|
||||
|
||||
/**
|
||||
* @param sb scrollbar object
|
||||
|
|
|
@ -39,16 +39,16 @@ typedef struct
|
|||
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
} TextboxFlags;
|
||||
|
||||
typedef enum
|
||||
|
@ -113,7 +113,7 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action );
|
|||
* The text should be one insert from a keypress.. the first gunichar is validated to be (or not) control
|
||||
* return TRUE if inserted
|
||||
*/
|
||||
gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len );
|
||||
gboolean textbox_append_char ( textbox *tb, const char *pad, const int pad_len );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
@ -138,7 +138,7 @@ void textbox_cursor ( textbox *tb, int pos );
|
|||
*
|
||||
* Insert the string str at position pos.
|
||||
*/
|
||||
void textbox_insert ( textbox *tb, int pos, char *str, int slen );
|
||||
void textbox_insert ( textbox *tb, const int pos, const char *str, const int slen );
|
||||
|
||||
/**
|
||||
* Setup the cached fonts. This is required to do
|
||||
|
@ -159,7 +159,7 @@ void textbox_cleanup ( void );
|
|||
*
|
||||
* @returns the height of the textbox in pixels.
|
||||
*/
|
||||
int textbox_get_height ( textbox *tb );
|
||||
int textbox_get_height ( const textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
@ -168,7 +168,7 @@ int textbox_get_height ( textbox *tb );
|
|||
*
|
||||
* @returns the width of the textbox in pixels.
|
||||
*/
|
||||
int textbox_get_width ( textbox *tb );
|
||||
int textbox_get_width ( const textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
@ -177,7 +177,7 @@ int textbox_get_width ( textbox *tb );
|
|||
*
|
||||
* @returns the height of the string in pixels.
|
||||
*/
|
||||
int textbox_get_font_height ( textbox *tb );
|
||||
int textbox_get_font_height ( const textbox *tb );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
@ -186,7 +186,7 @@ int textbox_get_font_height ( textbox *tb );
|
|||
*
|
||||
* @returns the width of the string in pixels.
|
||||
*/
|
||||
int textbox_get_font_width ( textbox *tb );
|
||||
int textbox_get_font_width ( const textbox *tb );
|
||||
|
||||
/**
|
||||
* Estimate the width of a character.
|
||||
|
@ -239,6 +239,11 @@ void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
|
|||
|
||||
PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
|
||||
|
||||
const char *textbox_get_visible_text ( textbox *tb );
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
* @returns the visible text.
|
||||
*/
|
||||
const char *textbox_get_visible_text ( const textbox *tb );
|
||||
/*@}*/
|
||||
#endif //ROFI_TEXTBOX_H
|
||||
|
|
|
@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
// Reading one line per time.
|
||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||
// Evaluate one line.
|
||||
unsigned int index = 0, ti = 0;
|
||||
unsigned int index = 0, ti = 0;
|
||||
char *token = buffer;
|
||||
|
||||
// Tokenize it.
|
||||
|
|
|
@ -204,7 +204,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
|||
}
|
||||
|
||||
char *saveptr = NULL, *token;
|
||||
GRegex **retv = NULL;
|
||||
GRegex **retv = NULL;
|
||||
if ( !config.tokenize ) {
|
||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
||||
|
@ -362,13 +362,14 @@ PangoAttrList *token_match_get_pango_attr ( GRegex **tokens, const char *input,
|
|||
return retv;
|
||||
}
|
||||
|
||||
int token_match ( GRegex **tokens, const char *input )
|
||||
|
||||
int token_match ( GRegex * const *tokens, const char *input )
|
||||
{
|
||||
int match = 1;
|
||||
// Do a tokenized match.
|
||||
if ( tokens ) {
|
||||
for ( int j = 0; match && tokens[j]; j++ ) {
|
||||
match = g_regex_match ( (GRegex *) tokens[j], input, 0, NULL );
|
||||
match = g_regex_match ( (const GRegex *) tokens[j], input, 0, NULL );
|
||||
}
|
||||
}
|
||||
return match;
|
||||
|
|
|
@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
|
|||
.keymap = NULL,
|
||||
.state = NULL,
|
||||
.compose = {
|
||||
.table = NULL,
|
||||
.state = NULL
|
||||
}
|
||||
.table = NULL,
|
||||
.state = NULL
|
||||
}
|
||||
};
|
||||
char *config_path = NULL;
|
||||
// Array of modi.
|
||||
|
@ -466,22 +466,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
|
|||
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
|
||||
break;
|
||||
case XCB_XKB_STATE_NOTIFY:
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
guint modmask;
|
||||
xkb_state_update_mask ( xkb.state,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
modmask = x11_get_current_mask ( &xkb );
|
||||
if ( modmask == 0 ) {
|
||||
abe_trigger_release ( );
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
guint modmask;
|
||||
xkb_state_update_mask ( xkb.state,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
modmask = x11_get_current_mask ( &xkb );
|
||||
if ( modmask == 0 ) {
|
||||
abe_trigger_release ( );
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ void scrollbar_resize ( scrollbar *sb, int w, int h )
|
|||
}
|
||||
}
|
||||
}
|
||||
unsigned int scrollbar_clicked ( scrollbar *sb, int y )
|
||||
unsigned int scrollbar_clicked ( const scrollbar *sb, int y )
|
||||
{
|
||||
if ( sb != NULL ) {
|
||||
if ( y >= sb->widget.y && y < ( sb->widget.y + sb->widget.h ) ) {
|
||||
|
|
|
@ -164,7 +164,7 @@ static void __textbox_update_pango_text ( textbox *tb )
|
|||
pango_layout_set_text ( tb->layout, tb->text, -1 );
|
||||
}
|
||||
}
|
||||
const char *textbox_get_visible_text ( textbox *tb )
|
||||
const char *textbox_get_visible_text ( const textbox *tb )
|
||||
{
|
||||
return pango_layout_get_text ( tb->layout );
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void textbox_cursor_end ( textbox *tb )
|
|||
}
|
||||
|
||||
// insert text
|
||||
void textbox_insert ( textbox *tb, int char_pos, char *str, int slen )
|
||||
void textbox_insert ( textbox *tb, const int char_pos, const char *str, const int slen )
|
||||
{
|
||||
char *c = g_utf8_offset_to_pointer ( tb->text, char_pos );
|
||||
int pos = c - tb->text;
|
||||
|
@ -634,7 +634,7 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
|
|||
}
|
||||
}
|
||||
|
||||
gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len )
|
||||
gboolean textbox_append_char ( textbox *tb, const char *pad, const int pad_len )
|
||||
{
|
||||
if ( !( tb->flags & TB_EDITABLE ) ) {
|
||||
return FALSE;
|
||||
|
@ -712,25 +712,25 @@ void textbox_cleanup ( void )
|
|||
}
|
||||
}
|
||||
|
||||
int textbox_get_width ( textbox *tb )
|
||||
int textbox_get_width ( const textbox *tb )
|
||||
{
|
||||
unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0;
|
||||
return textbox_get_font_width ( tb ) + 2 * SIDE_MARGIN + offset;
|
||||
}
|
||||
|
||||
int textbox_get_height ( textbox *tb )
|
||||
int textbox_get_height ( const textbox *tb )
|
||||
{
|
||||
return textbox_get_font_height ( tb ) + 2 * SIDE_MARGIN;
|
||||
}
|
||||
|
||||
int textbox_get_font_height ( textbox *tb )
|
||||
int textbox_get_font_height ( const textbox *tb )
|
||||
{
|
||||
int height;
|
||||
pango_layout_get_pixel_size ( tb->layout, NULL, &height );
|
||||
return height;
|
||||
}
|
||||
|
||||
int textbox_get_font_width ( textbox *tb )
|
||||
int textbox_get_font_width ( const textbox *tb )
|
||||
{
|
||||
int width;
|
||||
pango_layout_get_pixel_size ( tb->layout, &width, NULL );
|
||||
|
|
Loading…
Reference in a new issue