1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Indent files.

This commit is contained in:
Dave Davenport 2017-10-05 17:45:50 +02:00
parent 6ba31683c6
commit 9ae62960c1
20 changed files with 144 additions and 150 deletions

View file

@ -141,5 +141,5 @@ Settings config = {
.color_urgent = NULL, .color_urgent = NULL,
.color_window = NULL, .color_window = NULL,
.plugin_path = PLUGIN_PATH, .plugin_path = PLUGIN_PATH,
.max_history_size = 25, .max_history_size = 25,
}; };

View file

@ -316,7 +316,6 @@ gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_
*/ */
cairo_surface_t *cairo_image_surface_create_from_svg ( const gchar* file, int height ); cairo_surface_t *cairo_image_surface_create_from_svg ( const gchar* file, int height );
/** /**
* Ranges. * Ranges.
*/ */

View file

@ -216,7 +216,6 @@ typedef struct Property
PropertyValue value; PropertyValue value;
} Property; } Property;
/** /**
* Structure to hold a range. * Structure to hold a range.
*/ */
@ -226,11 +225,11 @@ typedef struct rofi_range_pair
unsigned int stop; unsigned int stop;
} rofi_range_pair; } rofi_range_pair;
/** /**
* Internal structure for matching. * Internal structure for matching.
*/ */
typedef struct rofi_int_matcher_t { typedef struct rofi_int_matcher_t
{
GRegex *regex; GRegex *regex;
gboolean invert; gboolean invert;
} rofi_int_matcher; } rofi_int_matcher;

View file

@ -91,7 +91,7 @@ void rofi_theme_property_free ( Property *p );
* *
* @returns a copy of p * @returns a copy of p
*/ */
Property* rofi_theme_property_copy ( Property *p); Property* rofi_theme_property_copy ( Property *p );
/** /**
* @param widget * @param widget
* *
@ -162,7 +162,6 @@ int rofi_theme_get_integer ( const widget *widget, const char *property, int
*/ */
int rofi_theme_get_position ( const widget *widget, const char *property, int def ); int rofi_theme_get_position ( const widget *widget, const char *property, int def );
/** /**
* @param widget The widget to query * @param widget The widget to query
* @param property The property to query. * @param property The property to query.
@ -288,7 +287,6 @@ GList *rofi_theme_get_list ( const widget *widget, const char * property, const
*/ */
gboolean rofi_theme_is_empty ( void ); gboolean rofi_theme_is_empty ( void );
/** /**
* Reset the current theme. * Reset the current theme.
*/ */

View file

@ -123,7 +123,7 @@ struct RofiViewState
int x; int x;
int y; int y;
widget *motion_target; widget *motion_target;
} mouse; } mouse;
/** Regexs used for matching */ /** Regexs used for matching */
rofi_int_matcher **tokens; rofi_int_matcher **tokens;

View file

@ -168,11 +168,11 @@ void x11_disable_decoration ( xcb_window_t window );
typedef enum typedef enum
{ {
/** Default EWHM compatible window manager */ /** Default EWHM compatible window manager */
WM_EWHM = 0, WM_EWHM = 0,
/** I3 Window manager */ /** I3 Window manager */
WM_DO_NOT_CHANGE_CURRENT_DESKTOP = 1, WM_DO_NOT_CHANGE_CURRENT_DESKTOP = 1,
/** PANGO WORKSPACE NAMES */ /** PANGO WORKSPACE NAMES */
WM_PANGO_WORKSPACE_NAMES = 2, WM_PANGO_WORKSPACE_NAMES = 2,
} WindowManagerQuirk; } WindowManagerQuirk;
/** /**

View file

@ -124,13 +124,13 @@ static int combi_mode_init ( Mode *sw )
} }
static unsigned int combi_mode_get_num_entries ( const Mode *sw ) static unsigned int combi_mode_get_num_entries ( const Mode *sw )
{ {
const CombiModePrivateData *pd = (const CombiModePrivateData *) mode_get_private_data ( sw ); const CombiModePrivateData *pd = (const CombiModePrivateData *) mode_get_private_data ( sw );
unsigned int length = 0; unsigned int length = 0;
for ( unsigned int i = 0; i < pd->num_switchers; i++ ) { for ( unsigned int i = 0; i < pd->num_switchers; i++ ) {
unsigned int entries = mode_get_num_entries ( pd->switchers[i].mode ); unsigned int entries = mode_get_num_entries ( pd->switchers[i].mode );
pd->starts[i] = length; pd->starts[i] = length;
pd->lengths[i] = entries; pd->lengths[i] = entries;
length+=entries; length += entries;
} }
return length; return length;
} }

View file

@ -67,33 +67,33 @@ typedef struct
{ {
/** Settings */ /** Settings */
// Separator. // Separator.
char separator; char separator;
unsigned int selected_line; unsigned int selected_line;
char *message; char *message;
char *format; char *format;
struct rofi_range_pair * urgent_list; struct rofi_range_pair * urgent_list;
unsigned int num_urgent_list; unsigned int num_urgent_list;
struct rofi_range_pair * active_list; struct rofi_range_pair * active_list;
unsigned int num_active_list; unsigned int num_active_list;
uint32_t *selected_list; uint32_t *selected_list;
unsigned int num_selected_list; unsigned int num_selected_list;
unsigned int do_markup; unsigned int do_markup;
// List with entries. // List with entries.
char **cmd_list; char **cmd_list;
unsigned int cmd_list_real_length; unsigned int cmd_list_real_length;
unsigned int cmd_list_length; unsigned int cmd_list_length;
unsigned int only_selected; unsigned int only_selected;
unsigned int selected_count; unsigned int selected_count;
gchar **columns; gchar **columns;
gchar *column_separator; gchar *column_separator;
gboolean multi_select; gboolean multi_select;
GCancellable *cancel; GCancellable *cancel;
gulong cancel_source; gulong cancel_source;
GInputStream *input_stream; GInputStream *input_stream;
GDataInputStream *data_input_stream; GDataInputStream *data_input_stream;
} DmenuModePrivateData; } DmenuModePrivateData;
static void async_close_callback ( GObject *source_object, GAsyncResult *res, G_GNUC_UNUSED gpointer user_data ) static void async_close_callback ( GObject *source_object, GAsyncResult *res, G_GNUC_UNUSED gpointer user_data )
@ -200,8 +200,6 @@ static unsigned int dmenu_mode_get_num_entries ( const Mode *sw )
return rmpd->cmd_list_length; return rmpd->cmd_list_length;
} }
static gchar * dmenu_format_output_string ( const DmenuModePrivateData *pd, const char *input ) static gchar * dmenu_format_output_string ( const DmenuModePrivateData *pd, const char *input )
{ {
if ( pd->columns == NULL ) { if ( pd->columns == NULL ) {
@ -613,7 +611,7 @@ int dmenu_switcher_dialog ( void )
find_arg_str ( "-select", &select ); find_arg_str ( "-select", &select );
if ( select != NULL ) { if ( select != NULL ) {
rofi_int_matcher **tokens = helper_tokenize ( select, config.case_sensitive ); rofi_int_matcher **tokens = helper_tokenize ( select, config.case_sensitive );
unsigned int i = 0; unsigned int i = 0;
for ( i = 0; i < cmd_list_length; i++ ) { for ( i = 0; i < cmd_list_length; i++ ) {
if ( helper_token_match ( tokens, cmd_list[i] ) ) { if ( helper_token_match ( tokens, cmd_list[i] ) ) {
pd->selected_line = i; pd->selected_line = i;
@ -624,7 +622,7 @@ int dmenu_switcher_dialog ( void )
} }
if ( find_arg ( "-dump" ) >= 0 ) { if ( find_arg ( "-dump" ) >= 0 ) {
rofi_int_matcher **tokens = helper_tokenize ( config.filter ? config.filter : "", config.case_sensitive ); rofi_int_matcher **tokens = helper_tokenize ( config.filter ? config.filter : "", config.case_sensitive );
unsigned int i = 0; unsigned int i = 0;
for ( i = 0; i < cmd_list_length; i++ ) { for ( i = 0; i < cmd_list_length; i++ ) {
if ( tokens == NULL || helper_token_match ( tokens, cmd_list[i] ) ) { if ( tokens == NULL || helper_token_match ( tokens, cmd_list[i] ) ) {
rofi_output_formatted_line ( pd->format, cmd_list[i], i, config.filter ); rofi_output_formatted_line ( pd->format, cmd_list[i], i, config.filter );

View file

@ -87,7 +87,7 @@ typedef struct
GKeyFile *key_file; GKeyFile *key_file;
gint sort_index; gint sort_index;
} DRunModeEntry; } DRunModeEntry;
typedef struct typedef struct
@ -212,7 +212,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
if ( helper_execute_command ( exec_path, fp, terminal, sn ? &context : NULL ) ) { if ( helper_execute_command ( exec_path, fp, terminal, sn ? &context : NULL ) ) {
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL ); char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
// Store it based on the unique identifiers (desktop_id). // Store it based on the unique identifiers (desktop_id).
history_set ( path, e->desktop_id); history_set ( path, e->desktop_id );
g_free ( path ); g_free ( path );
} }
g_free ( wmclass ); g_free ( wmclass );
@ -325,7 +325,8 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
if ( G_UNLIKELY ( pd->cmd_list_length > INT_MAX ) ) { if ( G_UNLIKELY ( pd->cmd_list_length > INT_MAX ) ) {
// Default to smallest value. // Default to smallest value.
pd->entry_list[pd->cmd_list_length].sort_index = INT_MIN; pd->entry_list[pd->cmd_list_length].sort_index = INT_MIN;
} else { }
else {
pd->entry_list[pd->cmd_list_length].sort_index = -pd->cmd_list_length; pd->entry_list[pd->cmd_list_length].sort_index = -pd->cmd_list_length;
} }
pd->entry_list[pd->cmd_list_length].icon_size = 0; pd->entry_list[pd->cmd_list_length].icon_size = 0;
@ -441,10 +442,11 @@ static void get_apps_history ( DRunModePrivateData *pd )
for ( unsigned int index = 0; index < length; index++ ) { for ( unsigned int index = 0; index < length; index++ ) {
for ( size_t i = 0; i < pd->cmd_list_length; i++ ) { for ( size_t i = 0; i < pd->cmd_list_length; i++ ) {
if ( g_strcmp0 ( pd->entry_list[i].desktop_id, retv[index] ) == 0 ) { if ( g_strcmp0 ( pd->entry_list[i].desktop_id, retv[index] ) == 0 ) {
unsigned int sort_index = length-index; unsigned int sort_index = length - index;
if ( G_LIKELY ( sort_index < INT_MAX ) ) { if ( G_LIKELY ( sort_index < INT_MAX ) ) {
pd->entry_list[i].sort_index = sort_index; pd->entry_list[i].sort_index = sort_index;
} else { }
else {
// This won't sort right anymore, but never gonna hit it anyway. // This won't sort right anymore, but never gonna hit it anyway.
pd->entry_list[i].sort_index = INT_MAX; pd->entry_list[i].sort_index = INT_MAX;
} }
@ -458,8 +460,8 @@ static void get_apps_history ( DRunModePrivateData *pd )
static gint drun_int_sort_list ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpointer user_data ) static gint drun_int_sort_list ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpointer user_data )
{ {
DRunModeEntry *da = (DRunModeEntry *)a; DRunModeEntry *da = (DRunModeEntry *) a;
DRunModeEntry *db = (DRunModeEntry *)b; DRunModeEntry *db = (DRunModeEntry *) b;
return db->sort_index - da->sort_index; return db->sort_index - da->sort_index;
} }
@ -494,8 +496,7 @@ static void get_apps ( DRunModePrivateData *pd )
TICK_N ( "Get Desktop apps (system dirs)" ); TICK_N ( "Get Desktop apps (system dirs)" );
get_apps_history ( pd ); get_apps_history ( pd );
g_qsort_with_data ( pd->entry_list, pd->cmd_list_length, sizeof ( DRunModeEntry ), drun_int_sort_list, NULL );
g_qsort_with_data ( pd->entry_list, pd->cmd_list_length, sizeof ( DRunModeEntry ) , drun_int_sort_list, NULL );
TICK_N ( "Sorting done." ); TICK_N ( "Sorting done." );
} }
@ -702,14 +703,14 @@ static int drun_token_match ( const Mode *data, rofi_int_matcher **tokens, unsig
int match = 1; int match = 1;
if ( tokens ) { if ( tokens ) {
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) { for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
int test = 0; int test = 0;
rofi_int_matcher *ftokens[2] = { tokens[j], NULL }; rofi_int_matcher *ftokens[2] = { tokens[j], NULL };
// Match name // Match name
if ( rmpd->entry_list[index].name ) { if ( rmpd->entry_list[index].name ) {
test = helper_token_match ( ftokens, rmpd->entry_list[index].name ); test = helper_token_match ( ftokens, rmpd->entry_list[index].name );
} }
// Match generic name // Match generic name
if ( test == tokens[j]->invert && rmpd->entry_list[index].generic_name) { if ( test == tokens[j]->invert && rmpd->entry_list[index].generic_name ) {
test = helper_token_match ( ftokens, rmpd->entry_list[index].generic_name ); test = helper_token_match ( ftokens, rmpd->entry_list[index].generic_name );
} }
// Match executable name. // Match executable name.

View file

@ -47,65 +47,64 @@
typedef struct typedef struct
{ {
/** ID of the current script. */ /** ID of the current script. */
unsigned int id; unsigned int id;
/** List of visible items. */ /** List of visible items. */
char **cmd_list; char **cmd_list;
/** length list of visible items. */ /** length list of visible items. */
unsigned int cmd_list_length; unsigned int cmd_list_length;
/** Urgent list */ /** Urgent list */
struct rofi_range_pair * urgent_list; struct rofi_range_pair * urgent_list;
unsigned int num_urgent_list; unsigned int num_urgent_list;
/** Active list */ /** Active list */
struct rofi_range_pair * active_list; struct rofi_range_pair * active_list;
unsigned int num_active_list; unsigned int num_active_list;
/** Configuration settings. */ /** Configuration settings. */
char *message; char *message;
char *prompt; char *prompt;
gboolean do_markup; gboolean do_markup;
} ScriptModePrivateData; } ScriptModePrivateData;
static void parse_header_entry ( Mode *sw, char *line, ssize_t length ) static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
{ {
ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data; ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data;
ssize_t length_key = 0;//strlen ( line ); ssize_t length_key = 0;//strlen ( line );
while ( line[length_key] != '\x1f' && length_key <= length ) { while ( line[length_key] != '\x1f' && length_key <= length ) {
length_key++; length_key++;
} }
if ( length_key < length ) if ( length_key < length ) {
{
line[length_key] = '\0'; line[length_key] = '\0';
char *value = line+length_key+1; char *value = line + length_key + 1;
if ( strcasecmp ( line, "message" ) == 0 ) { if ( strcasecmp ( line, "message" ) == 0 ) {
g_free ( pd->message ); g_free ( pd->message );
pd->message = g_strdup ( value ); pd->message = g_strdup ( value );
} else if ( strcasecmp ( line, "prompt" ) == 0 ) { }
else if ( strcasecmp ( line, "prompt" ) == 0 ) {
g_free ( pd->prompt ); g_free ( pd->prompt );
pd->prompt = g_strdup ( value ); pd->prompt = g_strdup ( value );
sw->display_name = pd->prompt; sw->display_name = pd->prompt;
} else if ( strcasecmp ( line, "markup-rows" ) == 0 ) { }
else if ( strcasecmp ( line, "markup-rows" ) == 0 ) {
pd->do_markup = ( strcasecmp ( value, "true" ) == 0 ); pd->do_markup = ( strcasecmp ( value, "true" ) == 0 );
} else if ( strcasecmp ( line, "urgent" ) == 0 ) { }
else if ( strcasecmp ( line, "urgent" ) == 0 ) {
parse_ranges ( value, &( pd->urgent_list ), &( pd->num_urgent_list ) ); parse_ranges ( value, &( pd->urgent_list ), &( pd->num_urgent_list ) );
} else if ( strcasecmp ( line, "active" ) == 0 ) { }
else if ( strcasecmp ( line, "active" ) == 0 ) {
parse_ranges ( value, &( pd->active_list ), &( pd->num_active_list ) ); parse_ranges ( value, &( pd->active_list ), &( pd->num_active_list ) );
} }
} }
} }
static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length ) static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length )
{ {
size_t actual_size = 0; size_t actual_size = 0;
int fd = -1; int fd = -1;
GError *error = NULL; GError *error = NULL;
char **retv = NULL; char **retv = NULL;
char **argv = NULL; char **argv = NULL;
int argc = 0; int argc = 0;
*length = 0; *length = 0;
if ( g_shell_parse_argv ( command, &argc, &argv, &error ) ) { if ( g_shell_parse_argv ( command, &argc, &argv, &error ) ) {
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) ); argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
@ -124,20 +123,21 @@ static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned i
if ( fd >= 0 ) { if ( fd >= 0 ) {
FILE *inp = fdopen ( fd, "r" ); FILE *inp = fdopen ( fd, "r" );
if ( inp ) { if ( inp ) {
char *buffer = NULL; char *buffer = NULL;
size_t buffer_length = 0; size_t buffer_length = 0;
ssize_t read_length = 0; ssize_t read_length = 0;
while ( (read_length = getline ( &buffer, &buffer_length, inp ) ) > 0 ) { while ( ( read_length = getline ( &buffer, &buffer_length, inp ) ) > 0 ) {
// Filter out line-end. // Filter out line-end.
if ( buffer[read_length-1] == '\n' ) { if ( buffer[read_length - 1] == '\n' ) {
buffer[read_length-1] = '\0'; buffer[read_length - 1] = '\0';
} }
if ( buffer[0] == '\0' ) { if ( buffer[0] == '\0' ) {
parse_header_entry ( sw, &buffer[1], read_length-1 ); parse_header_entry ( sw, &buffer[1], read_length - 1 );
} else { }
if ( actual_size < ((*length)+2) ){ else {
if ( actual_size < ( ( *length ) + 2 ) ) {
actual_size += 256; actual_size += 256;
retv = g_realloc ( retv, ( actual_size ) * sizeof ( char* ) ); retv = g_realloc ( retv, ( actual_size ) * sizeof ( char* ) );
} }
retv[( *length )] = g_strdup ( buffer ); retv[( *length )] = g_strdup ( buffer );
retv[( *length ) + 1] = NULL; retv[( *length ) + 1] = NULL;
@ -172,7 +172,6 @@ static void script_switcher_free ( Mode *sw )
g_free ( sw ); g_free ( sw );
} }
static int script_mode_init ( Mode *sw ) static int script_mode_init ( Mode *sw )
{ {
if ( sw->private_data == NULL ) { if ( sw->private_data == NULL ) {

View file

@ -482,7 +482,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
} }
if ( c->wmdesktop != 0xFFFFFFFF ) { if ( c->wmdesktop != 0xFFFFFFFF ) {
if ( has_names ) { if ( has_names ) {
if ( (current_window_manager&WM_PANGO_WORKSPACE_NAMES) == WM_PANGO_WORKSPACE_NAMES ) { if ( ( current_window_manager & WM_PANGO_WORKSPACE_NAMES ) == WM_PANGO_WORKSPACE_NAMES ) {
char *output = NULL; char *output = NULL;
if ( pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len, if ( pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len,
c->wmdesktop ), -1, 0, NULL, &output, NULL, NULL ) ) { c->wmdesktop ), -1, 0, NULL, &output, NULL, NULL ) ) {
@ -584,7 +584,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
} }
else { else {
rofi_view_hide (); rofi_view_hide ();
if ( ( current_window_manager&WM_DO_NOT_CHANGE_CURRENT_DESKTOP ) == 0 ) { if ( ( current_window_manager & WM_DO_NOT_CHANGE_CURRENT_DESKTOP ) == 0 ) {
// Get the desktop of the client to switch to // Get the desktop of the client to switch to
uint32_t wmdesktop = 0; uint32_t wmdesktop = 0;
xcb_get_property_cookie_t cookie; xcb_get_property_cookie_t cookie;

View file

@ -55,7 +55,6 @@
#include "rofi.h" #include "rofi.h"
#include "view.h" #include "view.h"
/** /**
* Textual description of positioning rofi. * Textual description of positioning rofi.
*/ */
@ -158,7 +157,6 @@ void helper_tokenize_free ( rofi_int_matcher ** tokens )
for ( size_t i = 0; tokens && tokens[i]; i++ ) { for ( size_t i = 0; tokens && tokens[i]; i++ ) {
g_regex_unref ( (GRegex *) tokens[i]->regex ); g_regex_unref ( (GRegex *) tokens[i]->regex );
g_free ( tokens[i] ); g_free ( tokens[i] );
} }
g_free ( tokens ); g_free ( tokens );
} }
@ -219,10 +217,10 @@ static inline GRegex * R ( const char *s, int case_sensitive )
static rofi_int_matcher * create_regex ( const char *input, int case_sensitive ) static rofi_int_matcher * create_regex ( const char *input, int case_sensitive )
{ {
GRegex * retv = NULL; GRegex * retv = NULL;
gchar *r; gchar *r;
rofi_int_matcher *rv = g_malloc0(sizeof(rofi_int_matcher)); rofi_int_matcher *rv = g_malloc0 ( sizeof ( rofi_int_matcher ) );
if ( input && input[0] == '-') { if ( input && input[0] == '-' ) {
rv->invert = 1; rv->invert = 1;
input++; input++;
} }
@ -265,7 +263,7 @@ rofi_int_matcher **helper_tokenize ( const char *input, int case_sensitive )
return NULL; return NULL;
} }
char *saveptr = NULL, *token; char *saveptr = NULL, *token;
rofi_int_matcher **retv = NULL; rofi_int_matcher **retv = NULL;
if ( !config.tokenize ) { if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( rofi_int_matcher* ) * 2 ); retv = g_malloc0 ( sizeof ( rofi_int_matcher* ) * 2 );
@ -415,7 +413,9 @@ PangoAttrList *helper_token_match_get_pango_attr ( RofiHighlightColorStyle th, r
if ( tokens ) { if ( tokens ) {
for ( int j = 0; tokens[j]; j++ ) { for ( int j = 0; tokens[j]; j++ ) {
GMatchInfo *gmi = NULL; GMatchInfo *gmi = NULL;
if ( tokens[j]->invert ) continue; if ( tokens[j]->invert ) {
continue;
}
g_regex_match ( tokens[j]->regex, input, G_REGEX_MATCH_PARTIAL, &gmi ); g_regex_match ( tokens[j]->regex, input, G_REGEX_MATCH_PARTIAL, &gmi );
while ( g_match_info_matches ( gmi ) ) { while ( g_match_info_matches ( gmi ) ) {
int count = g_match_info_get_match_count ( gmi ); int count = g_match_info_get_match_count ( gmi );
@ -476,7 +476,7 @@ int helper_token_match ( rofi_int_matcher* const *tokens, const char *input )
// Do a tokenized match. // Do a tokenized match.
if ( tokens ) { if ( tokens ) {
for ( int j = 0; match && tokens[j]; j++ ) { for ( int j = 0; match && tokens[j]; j++ ) {
match = g_regex_match ( tokens[j]->regex, input, 0, NULL ); match = g_regex_match ( tokens[j]->regex, input, 0, NULL );
match ^= tokens[j]->invert; match ^= tokens[j]->invert;
} }
} }

View file

@ -68,7 +68,7 @@ static void __history_write_element_list ( FILE *fd, _element **list, unsigned i
int min_value = list[length - 1]->index; int min_value = list[length - 1]->index;
// Set the max length of the list. // Set the max length of the list.
length = ( length > config.max_history_size ) ? config.max_history_size: length; length = ( length > config.max_history_size ) ? config.max_history_size : length;
// Write out entries. // Write out entries.
for ( unsigned int iter = 0; iter < length; iter++ ) { for ( unsigned int iter = 0; iter < length; iter++ ) {
@ -79,7 +79,7 @@ static void __history_write_element_list ( FILE *fd, _element **list, unsigned i
static _element ** __history_get_element_list ( FILE *fd, unsigned int *length ) static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
{ {
unsigned int real_length = 0; unsigned int real_length = 0;
_element **retv = NULL; _element **retv = NULL;
if ( length == NULL ) { if ( length == NULL ) {
return NULL; return NULL;
@ -107,8 +107,7 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
if ( ( l - ( start - buffer ) ) < 2 ) { if ( ( l - ( start - buffer ) ) < 2 ) {
continue; continue;
} }
if ( real_length < (*length+2) ) if ( real_length < ( *length + 2 ) ) {
{
real_length += 15; real_length += 15;
// Resize and check. // Resize and check.
retv = g_realloc ( retv, ( real_length ) * sizeof ( _element* ) ); retv = g_realloc ( retv, ( real_length ) * sizeof ( _element* ) );

View file

@ -551,7 +551,7 @@ static void rofi_collect_modi_destroy ( void )
g_module_close ( mod ); g_module_close ( mod );
} }
if ( available_modi[i] ) { if ( available_modi[i] ) {
mode_free ( &(available_modi[i]) ); mode_free ( &( available_modi[i] ) );
} }
} }
g_free ( available_modi ); g_free ( available_modi );
@ -582,7 +582,7 @@ static int add_mode ( const char * token )
Mode *sw = script_switcher_parse_setup ( token ); Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) { if ( sw != NULL ) {
// Add to available list, so combi can find it. // Add to available list, so combi can find it.
rofi_collect_modi_add(sw); rofi_collect_modi_add ( sw );
modi[num_modi] = sw; modi[num_modi] = sw;
num_modi++; num_modi++;
} }

View file

@ -74,24 +74,25 @@ Property *rofi_theme_property_create ( PropertyType type )
retv->type = type; retv->type = type;
return retv; return retv;
} }
Property* rofi_theme_property_copy ( Property *p) Property* rofi_theme_property_copy ( Property *p )
{ {
Property *retv = rofi_theme_property_create ( p->type ); Property *retv = rofi_theme_property_create ( p->type );
retv->name = g_strdup ( p->name ); retv->name = g_strdup ( p->name );
switch ( p->type ) { switch ( p->type )
case P_STRING: {
retv->value.s = g_strdup ( p->value.s ); case P_STRING:
break; retv->value.s = g_strdup ( p->value.s );
case P_LIST: break;
retv->value.list = g_list_copy_deep ( p->value.list, (GCopyFunc)g_strdup, NULL ); case P_LIST:
break; retv->value.list = g_list_copy_deep ( p->value.list, (GCopyFunc) g_strdup, NULL );
case P_LINK: break;
retv->value.link.name = g_strdup ( p->value.link.name ); case P_LINK:
retv->value.link.ref = NULL; retv->value.link.name = g_strdup ( p->value.link.name );
break; retv->value.link.ref = NULL;
default: break;
retv->value = p->value; default:
retv->value = p->value;
} }
return retv; return retv;
} }
@ -114,8 +115,8 @@ void rofi_theme_property_free ( Property *p )
void rofi_theme_reset ( void ) void rofi_theme_reset ( void )
{ {
rofi_theme_free ( rofi_theme ); rofi_theme_free ( rofi_theme );
rofi_theme = g_slice_new0 ( ThemeWidget ); rofi_theme = g_slice_new0 ( ThemeWidget );
rofi_theme->name = g_strdup("Root"); rofi_theme->name = g_strdup ( "Root" );
} }
void rofi_theme_free ( ThemeWidget *widget ) void rofi_theme_free ( ThemeWidget *widget )
@ -369,7 +370,7 @@ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
static void rofi_theme_copy_property_int ( G_GNUC_UNUSED gpointer key, gpointer value, gpointer user_data ) static void rofi_theme_copy_property_int ( G_GNUC_UNUSED gpointer key, gpointer value, gpointer user_data )
{ {
GHashTable *table = (GHashTable *) user_data; GHashTable *table = (GHashTable *) user_data;
Property *p = rofi_theme_property_copy( (Property*) value); Property *p = rofi_theme_property_copy ( (Property *) value );
g_hash_table_replace ( table, p->name, p ); g_hash_table_replace ( table, p->name, p );
} }
void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table ) void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
@ -378,7 +379,7 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
return; return;
} }
if ( widget->properties == NULL ) { if ( widget->properties == NULL ) {
widget->properties = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify)rofi_theme_property_free ); widget->properties = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify) rofi_theme_property_free );
} }
g_hash_table_foreach ( table, rofi_theme_copy_property_int, widget->properties ); g_hash_table_foreach ( table, rofi_theme_copy_property_int, widget->properties );
} }
@ -461,7 +462,7 @@ Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, con
while ( widget ) { while ( widget ) {
if ( widget->properties && g_hash_table_contains ( widget->properties, property ) ) { if ( widget->properties && g_hash_table_contains ( widget->properties, property ) ) {
Property *p = g_hash_table_lookup ( widget->properties, property ); Property *p = g_hash_table_lookup ( widget->properties, property );
if ( p ->type == P_INHERIT ) { if ( p->type == P_INHERIT ) {
return p; return p;
} }
if ( p->type == P_LINK ) { if ( p->type == P_LINK ) {
@ -632,7 +633,7 @@ void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t
if ( widget->parent ) { if ( widget->parent ) {
rofi_theme_get_color ( widget->parent, property, d ); rofi_theme_get_color ( widget->parent, property, d );
} }
return ; return;
} }
cairo_set_source_rgba ( d, cairo_set_source_rgba ( d,
p->value.color.red, p->value.color.red,
@ -677,7 +678,8 @@ GList *rofi_theme_get_list ( const widget *widget, const char * property, const
if ( widget->parent ) { if ( widget->parent ) {
return rofi_theme_get_list ( widget->parent, property, defaults ); return rofi_theme_get_list ( widget->parent, property, defaults );
} }
} else if ( p->type == P_LIST ) { }
else if ( p->type == P_LIST ) {
return g_list_copy_deep ( p->value.list, (GCopyFunc) g_strdup, NULL ); return g_list_copy_deep ( p->value.list, (GCopyFunc) g_strdup, NULL );
} }
} }

View file

@ -308,31 +308,31 @@ static void rofi_view_calculate_window_position ( RofiViewState *state )
{ {
case WL_NORTH_WEST: case WL_NORTH_WEST:
state->x = CacheState.mon.x; state->x = CacheState.mon.x;
/* FALLTHRU */ /* FALLTHRU */
case WL_NORTH: case WL_NORTH:
state->y = CacheState.mon.y; state->y = CacheState.mon.y;
break; break;
case WL_NORTH_EAST: case WL_NORTH_EAST:
state->y = CacheState.mon.y; state->y = CacheState.mon.y;
/* FALLTHRU */ /* FALLTHRU */
case WL_EAST: case WL_EAST:
state->x = CacheState.mon.x + CacheState.mon.w; state->x = CacheState.mon.x + CacheState.mon.w;
break; break;
case WL_SOUTH_EAST: case WL_SOUTH_EAST:
state->x = CacheState.mon.x + CacheState.mon.w; state->x = CacheState.mon.x + CacheState.mon.w;
/* FALLTHRU */ /* FALLTHRU */
case WL_SOUTH: case WL_SOUTH:
state->y = CacheState.mon.y + CacheState.mon.h; state->y = CacheState.mon.y + CacheState.mon.h;
break; break;
case WL_SOUTH_WEST: case WL_SOUTH_WEST:
state->y = CacheState.mon.y + CacheState.mon.h; state->y = CacheState.mon.y + CacheState.mon.h;
/* FALLTHRU */ /* FALLTHRU */
case WL_WEST: case WL_WEST:
state->x = CacheState.mon.x; state->x = CacheState.mon.x;
break; break;
case WL_CENTER: case WL_CENTER:
; ;
/* FALLTHRU */ /* FALLTHRU */
default: default:
break; break;
} }
@ -1364,10 +1364,10 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g
return FALSE; return FALSE;
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END: case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
target = NULL; target = NULL;
/* FALLTHRU */ /* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN: case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
state->mouse.motion_target = target; state->mouse.motion_target = target;
/* FALLTHRU */ /* FALLTHRU */
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED: case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
return TRUE; return TRUE;
} }
@ -1621,7 +1621,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
return; return;
} }
if ( config.sidebar_mode ) { if ( config.sidebar_mode ) {
state->sidebar_bar = box_create ( parent_widget, name,ROFI_ORIENTATION_HORIZONTAL ); state->sidebar_bar = box_create ( parent_widget, name, ROFI_ORIENTATION_HORIZONTAL );
box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE ); box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
state->num_modi = rofi_get_num_enabled_modi (); state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) ); state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
@ -1692,7 +1692,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
textbox_cursor_end ( state->text ); textbox_cursor_end ( state->text );
} }
state->overlay = textbox_create ( WIDGET ( state->main_window), WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 ); state->overlay = textbox_create ( WIDGET ( state->main_window ), WIDGET_TYPE_TEXTBOX_TEXT, "overlay", TB_AUTOWIDTH | TB_AUTOHEIGHT, URGENT, "blaat", 0.5, 0 );
widget_disable ( WIDGET ( state->overlay ) ); widget_disable ( WIDGET ( state->overlay ) );
// filtered list // filtered list

View file

@ -74,7 +74,7 @@ void container_add ( container *container, widget *child )
return; return;
} }
container->child = child; container->child = child;
g_assert ( child->parent == WIDGET ( container )); g_assert ( child->parent == WIDGET ( container ) );
widget_update ( WIDGET ( container ) ); widget_update ( WIDGET ( container ) );
} }

View file

@ -371,7 +371,7 @@ static void listview_recompute_elements ( listview *lv )
for ( unsigned int i = lv->cur_elements; i < newne; i++ ) { for ( unsigned int i = lv->cur_elements; i < newne; i++ ) {
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0; TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0;
flags |= ( ( config.show_icons ) ? TB_ICON : 0 ); flags |= ( ( config.show_icons ) ? TB_ICON : 0 );
lv->boxes[i] = textbox_create ( WIDGET (lv), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", flags, NORMAL, "", 0, 0 ); lv->boxes[i] = textbox_create ( WIDGET ( lv ), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", flags, NORMAL, "", 0, 0 );
widget_set_trigger_action_handler ( WIDGET ( lv->boxes[i] ), listview_element_trigger_action, lv ); widget_set_trigger_action_handler ( WIDGET ( lv->boxes[i] ), listview_element_trigger_action, lv );
} }
} }
@ -502,7 +502,7 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
break; break;
case ACCEPT_HOVERED_CUSTOM: case ACCEPT_HOVERED_CUSTOM:
custom = TRUE; custom = TRUE;
/* FALLTHRU */ /* FALLTHRU */
case ACCEPT_HOVERED_ENTRY: case ACCEPT_HOVERED_ENTRY:
listview_set_selected ( lv, lv->last_offset + i ); listview_set_selected ( lv, lv->last_offset + i );
lv->mouse_activated ( lv, custom, lv->mouse_activated_data ); lv->mouse_activated ( lv, custom, lv->mouse_activated_data );
@ -513,8 +513,8 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
listview *listview_create ( widget *parent, const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse ) listview *listview_create ( widget *parent, const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse )
{ {
listview *lv = g_malloc0 ( sizeof ( listview ) ); listview *lv = g_malloc0 ( sizeof ( listview ) );
widget_init ( WIDGET ( lv ), parent, WIDGET_TYPE_LISTVIEW, name ); widget_init ( WIDGET ( lv ), parent, WIDGET_TYPE_LISTVIEW, name );
lv->listview_name = g_strdup ( name ); lv->listview_name = g_strdup ( name );
lv->widget.free = listview_free; lv->widget.free = listview_free;
lv->widget.resize = listview_resize; lv->widget.resize = listview_resize;
@ -524,10 +524,10 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
lv->widget.get_desired_height = listview_get_desired_height; lv->widget.get_desired_height = listview_get_desired_height;
lv->eh = eh; lv->eh = eh;
lv->scrollbar = scrollbar_create ( WIDGET ( lv ) , "scrollbar" ); lv->scrollbar = scrollbar_create ( WIDGET ( lv ), "scrollbar" );
// Calculate height of an element. // Calculate height of an element.
// //
textbox *tb = textbox_create ( WIDGET (lv), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", 0, NORMAL, "", 0, 0 ); textbox *tb = textbox_create ( WIDGET ( lv ), WIDGET_TYPE_LISTVIEW_ELEMENT, "element", 0, NORMAL, "", 0, 0 );
lv->element_height = textbox_get_estimated_height ( tb, lv->eh ); lv->element_height = textbox_get_estimated_height ( tb, lv->eh );
widget_free ( WIDGET ( tb ) ); widget_free ( WIDGET ( tb ) );

View file

@ -182,7 +182,6 @@ textbox* textbox_create ( widget *parent, WidgetType type, const char *name, Tex
tb->layout = pango_layout_new ( p_context ); tb->layout = pango_layout_new ( p_context );
textbox_font ( tb, tbft ); textbox_font ( tb, tbft );
textbox_initialize_font ( tb ); textbox_initialize_font ( tb );
if ( ( tb->flags & TB_ICON ) != TB_ICON ) { if ( ( tb->flags & TB_ICON ) != TB_ICON ) {
@ -431,11 +430,11 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
int iconh = cairo_image_surface_get_height ( tb->icon ); int iconh = cairo_image_surface_get_height ( tb->icon );
int iconw = cairo_image_surface_get_width ( tb->icon ); int iconw = cairo_image_surface_get_width ( tb->icon );
int icons = MAX(iconh, iconw); int icons = MAX ( iconh, iconw );
double scale = (double) iconheight / icons; double scale = (double) iconheight / icons;
cairo_translate ( draw, x+(iconheight-iconw*scale)/2.0, y+(iconheight-iconh*scale)/2.0 ); cairo_translate ( draw, x + ( iconheight - iconw * scale ) / 2.0, y + ( iconheight - iconh * scale ) / 2.0 );
cairo_scale ( draw, scale, scale ); cairo_scale ( draw, scale, scale );
cairo_set_source_surface ( draw, tb->icon, 0,0); cairo_set_source_surface ( draw, tb->icon, 0, 0 );
cairo_paint ( draw ); cairo_paint ( draw );
cairo_restore ( draw ); cairo_restore ( draw );
} }

View file

@ -912,7 +912,7 @@ static void x11_helper_discover_window_manager ( void )
if ( wtitle.strings_len > 0 ) { if ( wtitle.strings_len > 0 ) {
g_debug ( "Found window manager: %s", wtitle.strings ); g_debug ( "Found window manager: %s", wtitle.strings );
if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) { if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) {
current_window_manager = WM_DO_NOT_CHANGE_CURRENT_DESKTOP|WM_PANGO_WORKSPACE_NAMES; current_window_manager = WM_DO_NOT_CHANGE_CURRENT_DESKTOP | WM_PANGO_WORKSPACE_NAMES;
} }
} }
xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle ); xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle );