1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Indent all the code.

This commit is contained in:
Dave Davenport 2020-02-02 13:56:37 +01:00
parent 83c2e467d5
commit b169289996
25 changed files with 840 additions and 832 deletions

View file

@ -1,7 +1,8 @@
#ifndef ROFI_DIALOGS_DMENU_SCRIPT_SHARED_H
#define ROFI_DIALOGS_DMENU_SCRIPT_SHARED_H
typedef struct {
typedef struct
{
/** Entry content. (visible part) */
char *entry;
/** Icon name to display. */

View file

@ -337,7 +337,6 @@ void parse_ranges ( char *input, rofi_range_pair **list, unsigned int *length );
*/
void rofi_output_formatted_line ( const char *format, const char *string, int selected_line, const char *filter );
/**
* @param string The string with elements to be replaced
* @param ... Set of {key}, value that will be replaced, terminated by a NULL

View file

@ -35,7 +35,8 @@
/**
* Describe the media constraint type.
*/
typedef enum {
typedef enum
{
/** Minimum width constraint. */
THEME_MEDIA_TYPE_MIN_WIDTH,
/** Maximum width constraint. */
@ -57,7 +58,8 @@ typedef enum {
/**
* Theme Media description.
*/
typedef struct ThemeMedia {
typedef struct ThemeMedia
{
ThemeMediaType type;
double value;
} ThemeMedia;

View file

@ -142,7 +142,6 @@ void widget_move ( widget *widget, short x, short y );
*/
WidgetType widget_type ( widget *widget );
/**
* @param widget Handle to widget
* @param type The widget type.

View file

@ -53,7 +53,6 @@
#include "dialogs/dmenuscriptshared.h"
static int dmenu_mode_init ( Mode *sw );
static int dmenu_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsigned int index );
static cairo_surface_t *dmenu_get_icon ( const Mode *sw, unsigned int selected_line, int height );
@ -250,8 +249,12 @@ static gchar * dmenu_format_output_string ( const DmenuModePrivateData *pd, cons
static inline unsigned int get_index ( unsigned int length, int index )
{
if ( index >= 0 ) return index;
if ( ((unsigned int)-index) <= length ) return (length+index);
if ( index >= 0 ) {
return index;
}
if ( ( (unsigned int) -index ) <= length ) {
return length + index;
}
// Out of range.
return UINT_MAX;
}
@ -443,8 +446,8 @@ static int dmenu_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsign
return retv;
}
return FALSE;
} else {
}
else {
return helper_token_match ( tokens, rmpd->cmd_list[index].entry );
}
}
@ -471,7 +474,6 @@ static cairo_surface_t *dmenu_get_icon ( const Mode *sw, unsigned int selected_l
return rofi_icon_fetcher_get ( dr->icon_fetch_uid );
}
static void dmenu_finish ( RofiViewState *state, int retv )
{
if ( retv == FALSE ) {

View file

@ -142,7 +142,6 @@ struct _DRunModePrivateData
unsigned int disabled_entries_length;
unsigned int expected_line_height;
char **show_categories;
// Theme
@ -237,8 +236,7 @@ static void exec_cmd_entry ( DRunModeEntry *e )
GKeyFile *kf = g_key_file_new ();
GError *error = NULL;
gboolean res = g_key_file_load_from_file ( kf, e->path, 0, &error );
if ( res )
{
if ( res ) {
e->key_file = kf;
}
else {
@ -282,7 +280,6 @@ static void exec_cmd_entry ( DRunModeEntry *e )
g_free ( str );
}
static gboolean rofi_strv_contains ( const char * const *categories, const char *const *field )
{
for ( int i = 0; categories && categories[i]; i++ ) {
@ -479,7 +476,8 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
if ( matching_entry_fields[DRUN_MATCH_FIELD_KEYWORDS].enabled ) {
pd->entry_list[pd->cmd_list_length].keywords = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Keywords", NULL, NULL, NULL );
} else {
}
else {
pd->entry_list[pd->cmd_list_length].keywords = NULL;
}
@ -487,7 +485,8 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
if ( categories ) {
pd->entry_list[pd->cmd_list_length].categories = categories;
categories = NULL;
} else {
}
else {
pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Categories", NULL, NULL, NULL );
}
}
@ -641,7 +640,8 @@ static gint drun_int_sort_list ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED
if ( da->sort_index < 0 && db->sort_index < 0 ) {
return g_utf8_collate ( da->name, db->name );
} else {
}
else {
return db->sort_index - da->sort_index;
}
}
@ -706,7 +706,9 @@ static void drun_read_stringv ( FILE *fd, char ***str )
static void write_cache ( DRunModePrivateData *pd, const char *cache_file )
{
if ( cache_file == NULL || config.drun_use_desktop_cache == FALSE ) return;
if ( cache_file == NULL || config.drun_use_desktop_cache == FALSE ) {
return;
}
TICK_N ( "DRUN Write CACHE: start" );
FILE *fd = fopen ( cache_file, "w" );
@ -718,8 +720,7 @@ static void write_cache ( DRunModePrivateData *pd, const char *cache_file )
fwrite ( &version, sizeof ( version ), 1, fd );
fwrite ( &( pd->cmd_list_length ), sizeof ( pd->cmd_list_length ), 1, fd );
for ( unsigned int index = 0; index < pd->cmd_list_length; index ++ )
{
for ( unsigned int index = 0; index < pd->cmd_list_length; index++ ) {
DRunModeEntry *entry = &( pd->entry_list[index] );
drun_write_str ( fd, entry->action );
@ -736,20 +737,20 @@ static void write_cache ( DRunModePrivateData *pd, const char *cache_file )
drun_write_strv ( fd, entry->keywords );
drun_write_str ( fd, entry->comment );
}
fclose ( fd );
TICK_N ( "DRUN Write CACHE: end" );
}
/**
* Read cache file. returns FALSE when success.
*/
static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_file )
{
if ( cache_file == NULL || config.drun_use_desktop_cache == FALSE ) return TRUE;
if ( cache_file == NULL || config.drun_use_desktop_cache == FALSE ) {
return TRUE;
}
if ( config.drun_reload_desktop_cache ) {
return TRUE;
@ -764,8 +765,7 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil
// Read version.
uint8_t version = 0;
if ( fread ( &version, sizeof(version),1, fd ) != 1 )
{
if ( fread ( &version, sizeof ( version ), 1, fd ) != 1 ) {
fclose ( fd );
g_warning ( "Cache corrupt, ignoring." );
TICK_N ( "DRUN Read CACHE: stop" );
@ -790,8 +790,7 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil
pd->entry_list = g_malloc0 ( pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) );
for ( unsigned int index = 0; index < pd->cmd_list_length; index++ )
{
for ( unsigned int index = 0; index < pd->cmd_list_length; index++ ) {
DRunModeEntry *entry = &( pd->entry_list[index] );
drun_read_string ( fd, &( entry->action ) );
@ -810,7 +809,6 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil
drun_read_string ( fd, &( entry->comment ) );
}
fclose ( fd );
TICK_N ( "DRUN Read CACHE: stop" );
return FALSE;
@ -820,9 +818,7 @@ static void get_apps ( DRunModePrivateData *pd )
{
char *cache_file = g_build_filename ( cache_dir, DRUN_DESKTOP_CACHE_FILE, NULL );
TICK_N ( "Get Desktop apps (start)" );
if ( drun_read_cache ( pd, cache_file ) )
{
if ( drun_read_cache ( pd, cache_file ) ) {
gchar *dir;
// First read the user directory.
dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL );
@ -1031,7 +1027,6 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
ec = g_markup_escape_text ( dr->comment, -1 );
}
char *retv = helper_string_replace_if_exists ( config.drun_display_format,
"{generic}", egn,
"{name}", en,

View file

@ -45,12 +45,10 @@
#include "mode-private.h"
#include "rofi-icon-fetcher.h"
#include "dialogs/dmenuscriptshared.h"
typedef struct
{
/** ID of the current script. */
@ -299,8 +297,12 @@ static void script_mode_destroy ( Mode *sw )
}
static inline unsigned int get_index ( unsigned int length, int index )
{
if ( index >= 0 ) return index;
if ( ((unsigned int)-index) <= length ) return (length+index);
if ( index >= 0 ) {
return index;
}
if ( ( (unsigned int) -index ) <= length ) {
return length + index;
}
// Out of range.
return UINT_MAX;
}

View file

@ -59,7 +59,8 @@
/**
* Holding an ssh entry.
*/
typedef struct _SshEntry {
typedef struct _SshEntry
{
/** SSH hostname */
char *hostname;
/** SSH port number */
@ -88,7 +89,6 @@ typedef struct
*/
#define SSH_TOKEN_DELIM "= \t\r\n"
/**
* @param entry The host to connect too
*
@ -146,7 +146,8 @@ static void exec_ssh ( const SshEntry *entry )
char *store = g_strdup_printf ( "%s\x1F%d", entry->hostname, entry->port );
history_set ( path, store );
g_free ( store );
} else {
}
else {
history_set ( path, entry->hostname );
}
g_free ( path );
@ -204,8 +205,7 @@ static SshEntry *read_known_hosts_file ( const char *path, SshEntry * retv, unsi
*end = '\0';
char *sep = start;
start = strsep ( &sep, ", " );
while ( start )
{
while ( start ) {
int port = 0;
if ( start[0] == '[' ) {
start++;
@ -217,11 +217,14 @@ static SshEntry *read_known_hosts_file ( const char *path, SshEntry * retv, unsi
gint64 number = g_ascii_strtoll ( &( end[2] ), &endptr, 10 );
if ( errno != 0 ) {
g_warning ( "Failed to parse port number: %s.", &( end[2] ) );
} else if ( endptr == &(end[2])) {
}
else if ( endptr == &( end[2] ) ) {
g_warning ( "Failed to parse port number: %s, invalid number.", &( end[2] ) );
} else if ( number < 0 || number > 65535 ) {
}
else if ( number < 0 || number > 65535 ) {
g_warning ( "Failed to parse port number: %s, out of range.", &( end[2] ) );
} else {
}
else {
port = number;
}
}
@ -254,7 +257,8 @@ static SshEntry *read_known_hosts_file ( const char *path, SshEntry * retv, unsi
if ( fclose ( fd ) != 0 ) {
g_warning ( "Failed to close hosts file: '%s'", g_strerror ( errno ) );
}
} else {
}
else {
g_debug ( "Failed to open KnownHostFile: '%s'", path );
}
@ -342,7 +346,8 @@ static void add_known_hosts_file ( SSHModePrivateData *pd, const char *token )
if ( item == NULL ) {
g_debug ( "Add '%s' to UserKnownHost list", token );
pd->user_known_hosts = g_list_append ( pd->user_known_hosts, g_strdup ( token ) );
} else {
}
else {
g_debug ( "File '%s' already in UserKnownHostsFile list", token );
}
}
@ -485,11 +490,14 @@ static SshEntry * get_ssh ( SSHModePrivateData *pd, unsigned int *length )
gint64 number = g_ascii_strtoll ( &( portstr[1] ), &endptr, 10 );
if ( errno != 0 ) {
g_warning ( "Failed to parse port number: %s.", &( portstr[1] ) );
} else if ( endptr == &(portstr[1])) {
}
else if ( endptr == &( portstr[1] ) ) {
g_warning ( "Failed to parse port number: %s, invalid number.", &( portstr[1] ) );
} else if ( number < 0 || number > 65535 ) {
}
else if ( number < 0 || number > 65535 ) {
g_warning ( "Failed to parse port number: %s, out of range.", &( portstr[1] ) );
} else {
}
else {
port = number;
}
}
@ -519,13 +527,11 @@ static SshEntry * get_ssh ( SSHModePrivateData *pd, unsigned int *length )
retv = read_hosts_file ( retv, length );
}
g_free ( path );
return retv;
}
/**
* @param sw Object handle to the SSH Mode object
*

View file

@ -79,7 +79,6 @@ void cmd_set_arguments ( int argc, char **argv )
stored_argv = argv;
}
int helper_parse_setup ( char * string, char ***output, int *length, ... )
{
GError *error = NULL;
@ -1135,8 +1134,9 @@ cairo_surface_t* cairo_image_surface_create_from_svg ( const gchar* file, int he
static void parse_pair ( char *input, rofi_range_pair *item )
{
// Skip leading blanks.
while ( input != NULL && isblank(*input) )
while ( input != NULL && isblank ( *input ) ) {
++input;
}
const char *sep[] = { "-", ":" };
int pythonic = ( strchr ( input, ':' ) || input[0] == '-' ) ? 1 : 0;
@ -1212,7 +1212,8 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se
if ( esc ) {
fputs ( esc, stdout );
g_free ( esc );
} else {
}
else {
fputs ( "invalid string", stdout );
}
}
@ -1241,7 +1242,6 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se
fflush ( stdout );
}
static gboolean helper_eval_cb2 ( const GMatchInfo *info, GString *res, gpointer data )
{
gchar *match;

View file

@ -663,7 +663,6 @@ static void show_error_dialog ()
rofi_view_error_dialog ( emesg->str, ERROR_MSG_MARKUP );
g_string_free ( emesg, TRUE );
rofi_set_return_code ( EX_DATAERR );
}
static gboolean startup ( G_GNUC_UNUSED gpointer data )
@ -856,7 +855,8 @@ int main ( int argc, char *argv[] )
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
g_debug ( "Parsing: %s", etc );
rofi_theme_parse_file ( etc );
} else {
}
else {
// Load distro default settings
gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) {
@ -976,7 +976,6 @@ int main ( int argc, char *argv[] )
return EXIT_SUCCESS;
}
if ( find_arg ( "-upgrade-config" ) >= 0 ) {
setup_modi ();
for ( unsigned int i = 0; i < num_modi; i++ ) {
@ -1013,7 +1012,8 @@ int main ( int argc, char *argv[] )
fflush ( fd );
fclose ( fd );
g_free ( fcpath );
} else {
}
else {
g_warning ( "Failed to get user configuration directory." );
cleanup ();
return EXIT_FAILURE;

View file

@ -147,17 +147,14 @@ static void rofi_theme_insert_listview_backwards_fix ( void )
ptb->value.color.alpha = 0.0;
g_hash_table_replace ( table, ptb->name, ptb );
rofi_theme_widget_add_properties ( tt, table );
RofiDistance dsize = (RofiDistance){ 1.2, ROFI_PU_CH, ROFI_HL_SOLID };
Property *pts = rofi_theme_property_create ( P_PADDING );
pts->value.padding.top = pts->value.padding.right = pts->value.padding.bottom = pts->value.padding.left = dsize;
pts->name = g_strdup ( "size" );
g_hash_table_replace ( table, pts->name, pts );
rofi_theme_widget_add_properties ( ti, table );
/** Add spacing between icon and text. */
@ -170,8 +167,6 @@ static void rofi_theme_insert_listview_backwards_fix ( void )
g_hash_table_replace ( table, psp->name, psp );
rofi_theme_widget_add_properties ( t, table );
g_hash_table_destroy ( table );
}
void rofi_theme_reset ( void )
@ -332,7 +327,8 @@ static void int_rofi_theme_print_property ( Property *p )
printf ( "var( %s, ", p->value.link.name );
int_rofi_theme_print_property ( p->value.link.def_value );
printf ( ")" );
}else {
}
else {
printf ( "var(%s)", p->value.link.name );
}
break;
@ -342,7 +338,6 @@ static void int_rofi_theme_print_property ( Property *p )
default:
break;
}
}
static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p )
@ -1022,7 +1017,6 @@ char * rofi_theme_parse_prepare_file ( const char *file, const char *parent_file
return filename;
}
void rofi_theme_parse_merge_widgets ( ThemeWidget *parent, ThemeWidget *child )
{
g_assert ( parent != NULL );
@ -1044,7 +1038,9 @@ void rofi_theme_parse_process_conditionals ( void )
{
workarea mon;
monitor_active ( &mon );
if ( rofi_theme == NULL ) return;
if ( rofi_theme == NULL ) {
return;
}
for ( unsigned int i = 0; i < rofi_theme->num_widgets; i++ ) {
ThemeWidget *widget = rofi_theme->widgets[i];
if ( widget->media != NULL ) {
@ -1128,24 +1124,28 @@ void rofi_theme_parse_process_conditionals ( void )
}
}
ThemeMediaType rofi_theme_parse_media_type ( const char *type )
{
if ( g_strcmp0 ( type, "monitor-id" ) == 0 ) {
return THEME_MEDIA_TYPE_MON_ID;
} else if ( g_strcmp0 ( type, "min-width") == 0 ) {
}
else if ( g_strcmp0 ( type, "min-width" ) == 0 ) {
return THEME_MEDIA_TYPE_MIN_WIDTH;
} else if ( g_strcmp0 ( type, "min-height") == 0 ) {
}
else if ( g_strcmp0 ( type, "min-height" ) == 0 ) {
return THEME_MEDIA_TYPE_MIN_HEIGHT;
} else if ( g_strcmp0 ( type, "max-width") == 0 ) {
}
else if ( g_strcmp0 ( type, "max-width" ) == 0 ) {
return THEME_MEDIA_TYPE_MAX_WIDTH;
} else if ( g_strcmp0 ( type, "max-height") == 0 ) {
}
else if ( g_strcmp0 ( type, "max-height" ) == 0 ) {
return THEME_MEDIA_TYPE_MAX_HEIGHT;
} else if ( g_strcmp0 ( type, "min-aspect-ratio") == 0 ) {
}
else if ( g_strcmp0 ( type, "min-aspect-ratio" ) == 0 ) {
return THEME_MEDIA_TYPE_MIN_ASPECT_RATIO;
} else if ( g_strcmp0 ( type, "max-aspect-ratio") == 0 ) {
}
else if ( g_strcmp0 ( type, "max-aspect-ratio" ) == 0 ) {
return THEME_MEDIA_TYPE_MAX_ASPECT_RATIO;
}
return THEME_MEDIA_TYPE_INVALID;
}

View file

@ -62,4 +62,3 @@ void rofi_timings_quit ( void )
g_debug ( "%4.6f (%2.6f): Stopped", now, 0.0 );
g_timer_destroy ( global_timer );
}

View file

@ -1117,8 +1117,6 @@ static void rofi_view_refilter ( RofiViewState *state )
}
TICK_N ( "Update filter lines" );
if ( config.auto_select == TRUE && state->filtered_lines == 1 && state->num_lines > 1 ) {
( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )];
state->retv = MENU_OK;
@ -1533,13 +1531,17 @@ static WidgetTriggerActionResult textbox_button_trigger_action ( widget *wid, Mo
( state->selected_line ) = state->line_map[listview_get_selected ( state->list_view )];
if ( strcmp ( type, "ok" ) == 0 ) {
state->retv = MENU_OK;
} else if ( strcmp ( type, "ok|alternate" ) == 0 ) {
}
else if ( strcmp ( type, "ok|alternate" ) == 0 ) {
state->retv = MENU_CUSTOM_ACTION | MENU_OK;
} else if ( strcmp ( type, "custom") ) {
}
else if ( strcmp ( type, "custom" ) ) {
state->retv = MENU_CUSTOM_INPUT;
} else if ( strcmp ( type, "custom|alternate" ) == 0 ) {
}
else if ( strcmp ( type, "custom|alternate" ) == 0 ) {
state->retv = MENU_CUSTOM_ACTION | MENU_CUSTOM_INPUT;
} else {
}
else {
g_warning ( "Invalid action specified." );
return WIDGET_TRIGGER_ACTION_RESULT_IGNORED;
}
@ -1609,7 +1611,8 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
if ( config.sidebar_mode ) {
defaults = "inputbar,message,listview,mode-switcher";
} else {
}
else {
defaults = "inputbar,message,listview";
}
}
@ -1783,7 +1786,8 @@ RofiViewState *rofi_view_create ( Mode *sw,
char * title = g_strdup_printf ( "rofi - %s", mode_get_display_name ( state->sw ) );
rofi_view_set_window_title ( title );
g_free ( title );
} else {
}
else {
rofi_view_set_window_title ( "rofi" );
}
TICK_N ( "Startup notification" );
@ -1804,7 +1808,6 @@ RofiViewState *rofi_view_create ( Mode *sw,
textbox_cursor_end ( state->text );
}
// filtered list
state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
state->distance = (int *) g_malloc0_n ( state->num_lines, sizeof ( int ) );
@ -1996,7 +1999,8 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
char * title = g_strdup_printf ( "rofi - %s", mode_get_display_name ( state->sw ) );
rofi_view_set_window_title ( title );
g_free ( title );
} else {
}
else {
rofi_view_set_window_title ( "rofi" );
}
if ( state->sidebar_bar ) {

View file

@ -62,7 +62,8 @@ typedef enum
RIGHT_TO_LEFT = 1
} MoveDirection;
typedef struct {
typedef struct
{
box *box;
textbox *textbox;
textbox *index;
@ -121,7 +122,6 @@ struct _listview
char *listview_name;
PangoEllipsizeMode emode;
/** Barview */
struct
@ -184,10 +184,12 @@ static void listview_create_row ( listview *lv, _listview_row *row )
row->icon = icon_create ( WIDGET ( row->box ), "element-icon" );
box_add ( row->box, WIDGET ( row->icon ), FALSE );
}
} else if ( strcasecmp ((char *)iter->data, "element-text") == 0 ){
}
else if ( strcasecmp ( (char *) iter->data, "element-text" ) == 0 ) {
row->textbox = textbox_create ( WIDGET ( row->box ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
box_add ( row->box, WIDGET ( row->textbox ), TRUE );
} else if ( strcasecmp ( (char*)iter->data, "element-index" ) == 0 ){
}
else if ( strcasecmp ( (char*) iter->data, "element-index" ) == 0 ) {
row->index = textbox_create ( WIDGET ( row->box ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
box_add ( row->box, WIDGET ( row->index ), FALSE );
}
@ -195,7 +197,6 @@ static void listview_create_row ( listview *lv, _listview_row *row )
g_list_free_full ( list, g_free );
}
static void listview_set_state ( _listview_row r, TextBoxFontType type )
{
listview_set_style ( WIDGET ( r.box ), type );
@ -297,7 +298,8 @@ static void update_element ( listview *lv, unsigned int tb, unsigned int index,
'\0'
};
textbox_text ( lv->boxes[tb].index, str );
} else {
}
else {
textbox_text ( lv->boxes[tb].index, " " );
}
}
@ -429,8 +431,7 @@ static void listview_draw ( widget *wid, cairo_t *draw )
unsigned int element_width = ( width - spacing_hori * ( lv->cur_columns - 1 ) ) / lv->cur_columns;
int d = width - ( element_width + spacing_hori ) * ( lv->cur_columns - 1 ) - element_width;
if ( lv->cur_columns > 1)
{
if ( lv->cur_columns > 1 ) {
int diff = d / ( lv->cur_columns - 1 );
if ( diff >= 1 ) {
spacing_hori += 1;
@ -458,7 +459,6 @@ static void listview_draw ( widget *wid, cairo_t *draw )
widget_draw ( WIDGET ( lv->boxes[i].box ), draw );
}
lv->rchanged = FALSE;
}
else {
for ( unsigned int i = 0; i < max; i++ ) {
@ -970,9 +970,11 @@ void listview_toggle_ellipsizing ( listview *lv )
PangoEllipsizeMode mode = lv->emode;
if ( mode == PANGO_ELLIPSIZE_START ) {
mode = PANGO_ELLIPSIZE_MIDDLE;
} else if ( mode == PANGO_ELLIPSIZE_MIDDLE ) {
}
else if ( mode == PANGO_ELLIPSIZE_MIDDLE ) {
mode = PANGO_ELLIPSIZE_END;
} else if ( mode == PANGO_ELLIPSIZE_END ) {
}
else if ( mode == PANGO_ELLIPSIZE_END ) {
mode = PANGO_ELLIPSIZE_START;
}
lv->emode = mode;

View file

@ -268,8 +268,7 @@ void textbox_font ( textbox *tb, TextBoxFontType tbft )
static void __textbox_update_pango_text ( textbox *tb )
{
pango_layout_set_attributes ( tb->layout, NULL );
if ( tb->placeholder && (tb->text == NULL || tb->text[0] == 0) )
{
if ( tb->placeholder && ( tb->text == NULL || tb->text[0] == 0 ) ) {
tb->show_placeholder = TRUE;
pango_layout_set_text ( tb->layout, tb->placeholder, -1 );
return;
@ -344,7 +343,6 @@ void textbox_text ( textbox *tb, const char *text )
widget_queue_redraw ( WIDGET ( tb ) );
}
// within the parent handled auto width/height modes
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
{
@ -360,7 +358,8 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
}
else if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) {
pango_layout_set_ellipsize ( tb->layout, tb->emode );
} else {
}
else {
pango_layout_set_ellipsize ( tb->layout, PANGO_ELLIPSIZE_NONE );
}
}
@ -450,7 +449,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
cairo_move_to ( draw, x, top );
pango_cairo_show_layout ( draw, tb->layout );
// draw the cursor
rofi_theme_get_color ( WIDGET ( tb ), "text-color", draw );
if ( tb->flags & TB_EDITABLE && tb->blink ) {
@ -470,7 +468,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
cairo_fill ( draw );
}
if ( ( tb->flags & TB_INDICATOR ) == TB_INDICATOR && ( tb->tbft & ( SELECTED ) ) ) {
cairo_arc ( draw, DOT_OFFSET / 2.0, tb->widget.h / 2.0, 2.0, 0, 2.0 * M_PI );
cairo_fill ( draw );
@ -941,11 +938,9 @@ int textbox_get_desired_width ( widget *wid )
return width + padding + offset;
}
void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode )
{
if ( tb )
{
if ( tb ) {
tb->emode = mode;
if ( ( tb->flags & TB_WRAP ) != TB_WRAP ) {
// Store the mode.

View file

@ -106,14 +106,14 @@ static xcb_visualtype_t * lookup_visual (xcb_screen_t *s, xcb_visualid_t visu
for (; d.rem; xcb_depth_next ( &d ) ) {
xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator ( d.data );
for (; v.rem; xcb_visualtype_next ( &v ) ) {
if (v.data->visual_id == visual)
if ( v.data->visual_id == visual ) {
return v.data;
}
}
}
return 0;
}
cairo_surface_t *x11_helper_get_screenshot_surface_window ( xcb_window_t window, int size )
{
xcb_get_geometry_cookie_t cookie;
@ -131,7 +131,9 @@ cairo_surface_t *x11_helper_get_screenshot_surface_window ( xcb_window_t window,
NULL );
if ( attributes == NULL || ( attributes->map_state != XCB_MAP_STATE_VIEWABLE ) ) {
free ( reply );
if ( attributes ) free(attributes);
if ( attributes ) {
free ( attributes );
}
return NULL;
}
// Create a cairo surface for the window.