1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -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

@ -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 );
/**
* Ranges.
*/

View file

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

View file

@ -91,7 +91,7 @@ void rofi_theme_property_free ( Property *p );
*
* @returns a copy of p
*/
Property* rofi_theme_property_copy ( Property *p);
Property* rofi_theme_property_copy ( Property *p );
/**
* @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 );
/**
* @param widget The widget 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 );
/**
* Reset the current theme.
*/

View file

@ -130,7 +130,7 @@ static unsigned int combi_mode_get_num_entries ( const Mode *sw )
unsigned int entries = mode_get_num_entries ( pd->switchers[i].mode );
pd->starts[i] = length;
pd->lengths[i] = entries;
length+=entries;
length += entries;
}
return length;
}

View file

@ -200,8 +200,6 @@ static unsigned int dmenu_mode_get_num_entries ( const Mode *sw )
return rmpd->cmd_list_length;
}
static gchar * dmenu_format_output_string ( const DmenuModePrivateData *pd, const char *input )
{
if ( pd->columns == NULL ) {

View file

@ -212,7 +212,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
if ( helper_execute_command ( exec_path, fp, terminal, sn ? &context : NULL ) ) {
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
// 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 ( 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 ) ) {
// Default to smallest value.
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].icon_size = 0;
@ -441,10 +442,11 @@ static void get_apps_history ( DRunModePrivateData *pd )
for ( unsigned int index = 0; index < length; index++ ) {
for ( size_t i = 0; i < pd->cmd_list_length; i++ ) {
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 ) ) {
pd->entry_list[i].sort_index = sort_index;
} else {
}
else {
// This won't sort right anymore, but never gonna hit it anyway.
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 )
{
DRunModeEntry *da = (DRunModeEntry *)a;
DRunModeEntry *db = (DRunModeEntry *)b;
DRunModeEntry *da = (DRunModeEntry *) a;
DRunModeEntry *db = (DRunModeEntry *) b;
return db->sort_index - da->sort_index;
}
@ -494,8 +496,7 @@ static void get_apps ( DRunModePrivateData *pd )
TICK_N ( "Get Desktop apps (system dirs)" );
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." );
}
@ -709,7 +710,7 @@ static int drun_token_match ( const Mode *data, rofi_int_matcher **tokens, unsig
test = helper_token_match ( ftokens, rmpd->entry_list[index].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 );
}
// Match executable name.

View file

@ -63,7 +63,6 @@ typedef struct
char *message;
char *prompt;
gboolean do_markup;
} ScriptModePrivateData;
static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
@ -74,30 +73,30 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
length_key++;
}
if ( length_key < length )
{
if ( length_key < length ) {
line[length_key] = '\0';
char *value = line+length_key+1;
char *value = line + length_key + 1;
if ( strcasecmp ( line, "message" ) == 0 ) {
g_free ( pd->message );
pd->message = g_strdup ( value );
} else if ( strcasecmp ( line, "prompt" ) == 0 ) {
}
else if ( strcasecmp ( line, "prompt" ) == 0 ) {
g_free ( pd->prompt );
pd->prompt = g_strdup ( value );
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 );
} else if ( strcasecmp ( line, "urgent" ) == 0 ) {
}
else if ( strcasecmp ( line, "urgent" ) == 0 ) {
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 ) );
}
}
}
static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length )
{
size_t actual_size = 0;
@ -127,15 +126,16 @@ static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned i
char *buffer = NULL;
size_t buffer_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.
if ( buffer[read_length-1] == '\n' ) {
buffer[read_length-1] = '\0';
if ( buffer[read_length - 1] == '\n' ) {
buffer[read_length - 1] = '\0';
}
if ( buffer[0] == '\0' ) {
parse_header_entry ( sw, &buffer[1], read_length-1 );
} else {
if ( actual_size < ((*length)+2) ){
parse_header_entry ( sw, &buffer[1], read_length - 1 );
}
else {
if ( actual_size < ( ( *length ) + 2 ) ) {
actual_size += 256;
retv = g_realloc ( retv, ( actual_size ) * sizeof ( char* ) );
}
@ -172,7 +172,6 @@ static void script_switcher_free ( Mode *sw )
g_free ( sw );
}
static int script_mode_init ( Mode *sw )
{
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 ( 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;
if ( pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len,
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 {
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
uint32_t wmdesktop = 0;
xcb_get_property_cookie_t cookie;

View file

@ -55,7 +55,6 @@
#include "rofi.h"
#include "view.h"
/**
* 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++ ) {
g_regex_unref ( (GRegex *) tokens[i]->regex );
g_free ( tokens[i] );
}
g_free ( tokens );
}
@ -221,8 +219,8 @@ static rofi_int_matcher * create_regex ( const char *input, int case_sensitive )
{
GRegex * retv = NULL;
gchar *r;
rofi_int_matcher *rv = g_malloc0(sizeof(rofi_int_matcher));
if ( input && input[0] == '-') {
rofi_int_matcher *rv = g_malloc0 ( sizeof ( rofi_int_matcher ) );
if ( input && input[0] == '-' ) {
rv->invert = 1;
input++;
}
@ -415,7 +413,9 @@ PangoAttrList *helper_token_match_get_pango_attr ( RofiHighlightColorStyle th, r
if ( tokens ) {
for ( int j = 0; tokens[j]; j++ ) {
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 );
while ( g_match_info_matches ( gmi ) ) {
int count = g_match_info_get_match_count ( gmi );

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;
// 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.
for ( unsigned int iter = 0; iter < length; iter++ ) {
@ -107,8 +107,7 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
if ( ( l - ( start - buffer ) ) < 2 ) {
continue;
}
if ( real_length < (*length+2) )
{
if ( real_length < ( *length + 2 ) ) {
real_length += 15;
// Resize and check.
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 );
}
if ( available_modi[i] ) {
mode_free ( &(available_modi[i]) );
mode_free ( &( available_modi[i] ) );
}
}
g_free ( available_modi );
@ -582,7 +582,7 @@ static int add_mode ( const char * token )
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
// Add to available list, so combi can find it.
rofi_collect_modi_add(sw);
rofi_collect_modi_add ( sw );
modi[num_modi] = sw;
num_modi++;
}

View file

@ -74,17 +74,18 @@ Property *rofi_theme_property_create ( PropertyType type )
retv->type = type;
return retv;
}
Property* rofi_theme_property_copy ( Property *p)
Property* rofi_theme_property_copy ( Property *p )
{
Property *retv = rofi_theme_property_create ( p->type );
retv->name = g_strdup ( p->name );
switch ( p->type ) {
switch ( p->type )
{
case P_STRING:
retv->value.s = g_strdup ( p->value.s );
break;
case P_LIST:
retv->value.list = g_list_copy_deep ( p->value.list, (GCopyFunc)g_strdup, NULL );
retv->value.list = g_list_copy_deep ( p->value.list, (GCopyFunc) g_strdup, NULL );
break;
case P_LINK:
retv->value.link.name = g_strdup ( p->value.link.name );
@ -115,7 +116,7 @@ void rofi_theme_reset ( void )
{
rofi_theme_free ( rofi_theme );
rofi_theme = g_slice_new0 ( ThemeWidget );
rofi_theme->name = g_strdup("Root");
rofi_theme->name = g_strdup ( "Root" );
}
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 )
{
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 );
}
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;
}
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 );
}
@ -461,7 +462,7 @@ Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, con
while ( widget ) {
if ( widget->properties && g_hash_table_contains ( widget->properties, property ) ) {
Property *p = g_hash_table_lookup ( widget->properties, property );
if ( p ->type == P_INHERIT ) {
if ( p->type == P_INHERIT ) {
return p;
}
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 ) {
rofi_theme_get_color ( widget->parent, property, d );
}
return ;
return;
}
cairo_set_source_rgba ( d,
p->value.color.red,
@ -677,7 +678,8 @@ GList *rofi_theme_get_list ( const widget *widget, const char * property, const
if ( widget->parent ) {
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 );
}
}

View file

@ -1621,7 +1621,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
return;
}
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 );
state->num_modi = rofi_get_num_enabled_modi ();
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
@ -1692,7 +1692,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
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 ) );
// filtered list

View file

@ -74,7 +74,7 @@ void container_add ( container *container, widget *child )
return;
}
container->child = child;
g_assert ( child->parent == WIDGET ( container ));
g_assert ( child->parent == 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++ ) {
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 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 );
}
}
@ -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->eh = eh;
lv->scrollbar = scrollbar_create ( WIDGET ( lv ) , "scrollbar" );
lv->scrollbar = scrollbar_create ( WIDGET ( lv ), "scrollbar" );
// 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 );
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 );
textbox_font ( tb, tbft );
textbox_initialize_font ( tb );
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 iconw = cairo_image_surface_get_width ( tb->icon );
int icons = MAX(iconh, iconw);
int icons = MAX ( iconh, iconw );
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_set_source_surface ( draw, tb->icon, 0,0);
cairo_set_source_surface ( draw, tb->icon, 0, 0 );
cairo_paint ( draw );
cairo_restore ( draw );
}

View file

@ -912,7 +912,7 @@ static void x11_helper_discover_window_manager ( void )
if ( wtitle.strings_len > 0 ) {
g_debug ( "Found window manager: %s", wtitle.strings );
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 );