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

Run indenter.

This commit is contained in:
Dave Davenport 2020-08-28 16:41:59 +02:00
parent 5bec191d2e
commit 30735791b4
21 changed files with 349 additions and 331 deletions

View file

@ -119,7 +119,6 @@ typedef struct RofiDistanceUnit
/** Modifier */
struct RofiDistanceUnit *right;
} RofiDistanceUnit;
typedef struct

View file

@ -249,7 +249,6 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub
*/
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );
/**
* @param widget The widget to query
* @param property The property to query.

View file

@ -307,7 +307,6 @@ void rofi_capture_screenshot ( void );
*/
void rofi_view_set_window_title ( const char * title );
/**
* set ellipsize mode to start.
*/

View file

@ -172,7 +172,8 @@ void widget_set_enabled ( widget *widget, gboolean enabled );
* Disable the widget.
*/
static inline
void widget_disable ( widget *widget ) {
void widget_disable ( widget *widget )
{
widget_set_enabled ( widget, FALSE );
}
/**
@ -181,7 +182,8 @@ void widget_disable ( widget *widget ) {
* Enable the widget.
*/
static inline
void widget_enable ( widget *widget ) {
void widget_enable ( widget *widget )
{
widget_set_enabled ( widget, TRUE );
}

View file

@ -736,7 +736,6 @@ int dmenu_switcher_dialog ( void )
find_arg_str ( "-p", &( dmenu_mode.display_name ) );
RofiViewState *state = rofi_view_create ( &dmenu_mode, input, menu_flags, dmenu_finalize );
if ( find_arg ( "-keep-right" ) >= 0 ) {
rofi_view_ellipsize_start ( state );
}

View file

@ -393,9 +393,11 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
}
if ( !g_strcmp0 ( key, "Application" ) ) {
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_APPLICATION;
} else if ( !g_strcmp0 ( key, "Link" ) ) {
}
else if ( !g_strcmp0 ( key, "Link" ) ) {
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_LINK;
} else {
}
else {
g_debug ( "[%s] [%s] Skipping desktop file: Not of type Application or Link (%s)", id, path, key );
g_free ( key );
g_key_file_free ( kf );
@ -563,7 +565,8 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
pd->entry_list[pd->cmd_list_length].type = desktop_entry_type;
if ( desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_APPLICATION ) {
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, action, "Exec", NULL );
} else {
}
else {
pd->entry_list[pd->cmd_list_length].exec = NULL;
}
@ -1019,7 +1022,8 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
retv = ( mretv & MENU_LOWER_MASK );
}
else if ( ( mretv & MENU_OK ) ) {
switch ( rmpd->entry_list[selected_line].type ) {
switch ( rmpd->entry_list[selected_line].type )
{
case DRUN_DESKTOP_ENTRY_TYPE_APPLICATION:
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
break;

View file

@ -80,8 +80,7 @@ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *
{
gchar **extras = g_strsplit ( buffer, "\x1f", -1 );
gchar **extra;
for ( extra = extras ; *extra != NULL && *(extra + 1) != NULL ; extra += 2 )
{
for ( extra = extras; *extra != NULL && *( extra + 1 ) != NULL; extra += 2 ) {
gchar *key = *extra;
gchar *value = *( extra + 1 );
if ( strcasecmp ( key, "icon" ) == 0 ) {
@ -140,7 +139,8 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
}
else if ( strcasecmp ( line, "delim" ) == 0 ) {
pd->delim = helper_parse_char ( value );
} else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
}
else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
pd->no_custom = ( strcasecmp ( value, "true" ) == 0 );
}
}
@ -156,7 +156,6 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
int argc = 0;
*length = 0;
// Environment
char ** env = g_get_environ ();
@ -172,7 +171,6 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
env = g_environ_setenv ( env, "ROFI_INFO", entry->info, TRUE );
}
if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
argv[argc] = g_strdup ( arg );
@ -291,10 +289,12 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
script_mode_reset_highlight ( sw );
if ( selected_line != UINT32_MAX ) {
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) );
} else {
}
else {
if ( rmpd->no_custom == FALSE ) {
new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL );
} else {
}
else {
return RELOAD_DIALOG;
}
}
@ -310,7 +310,8 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
if ( rmpd->no_custom == FALSE ) {
script_mode_reset_highlight ( sw );
new_list = execute_executor ( sw, *input, &new_length, 2, NULL );
} else {
}
else {
return RELOAD_DIALOG;
}
}

View file

@ -133,9 +133,8 @@ void rofi_icon_fetcher_destroy ( void )
g_free ( rofi_icon_fetcher_data );
}
static cairo_surface_t* cairo_image_surface_create_from_jpeg_private(struct jpeg_decompress_struct* cinfo) {
static cairo_surface_t* cairo_image_surface_create_from_jpeg_private ( struct jpeg_decompress_struct* cinfo )
{
cairo_surface_t* surface = 0;
unsigned char * data = 0;
unsigned char * rgb = 0;
@ -173,13 +172,16 @@ static cairo_surface_t* cairo_image_surface_create_from_jpeg_private(struct jpeg
return surface;
}
static cairo_surface_t* cairo_image_surface_create_from_jpeg(const char* file) {
static cairo_surface_t* cairo_image_surface_create_from_jpeg ( const char* file )
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cairo_surface_t * surface;
FILE * infile;
if((infile = fopen(file, "rb")) == NULL) return NULL;
if ( ( infile = fopen ( file, "rb" ) ) == NULL ) {
return NULL;
}
cinfo.err = jpeg_std_error ( &jerr );
@ -239,8 +241,7 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
float sh = sentry->size / (float) cairo_image_surface_get_height ( icon_surf );
float scale = ( sw > sh ) ? sh : sw;
if ( scale < 0.5 )
{
if ( scale < 0.5 ) {
cairo_surface_t * surface = cairo_image_surface_create (
cairo_image_surface_get_format ( icon_surf ),
cairo_image_surface_get_width ( icon_surf ) * scale,
@ -256,8 +257,6 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
cairo_surface_destroy ( icon_surf );
icon_surf = surface;
}
}
// check if surface is valid.
if ( cairo_surface_status ( icon_surf ) != CAIRO_STATUS_SUCCESS ) {

View file

@ -882,8 +882,7 @@ int main ( int argc, char *argv[] )
// Load distro default settings
gboolean found_system = FALSE;
const char * const * dirs = g_get_system_config_dirs ();
if ( dirs )
{
if ( dirs ) {
for ( unsigned int i = 0; !found_system && dirs[i]; i++ ) {
/** New format. */
gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL );
@ -892,7 +891,8 @@ int main ( int argc, char *argv[] )
g_debug ( "Parsing: %s", etc );
rofi_theme_parse_file ( etc );
found_system = TRUE;
} else {
}
else {
/** Old format. */
gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL );
g_debug ( "Look for default config file: %s", xetc );
@ -913,7 +913,8 @@ int main ( int argc, char *argv[] )
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
g_debug ( "Look for default config file: %s", etc );
rofi_theme_parse_file ( etc );
} else {
}
else {
/** Old format. */
gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
g_debug ( "Look for default config file: %s", xetc );

View file

@ -97,12 +97,10 @@ static RofiDistanceUnit *rofi_theme_property_copy_distance_unit ( RofiDistanceU
RofiDistance rofi_theme_property_copy_distance ( RofiDistance const distance )
{
RofiDistance retv = distance;
if ( distance.base.left )
{
if ( distance.base.left ) {
retv.base.left = rofi_theme_property_copy_distance_unit ( distance.base.left );
}
if ( distance.base.right )
{
if ( distance.base.right ) {
retv.base.right = rofi_theme_property_copy_distance_unit ( distance.base.right );
}
return retv;
@ -277,27 +275,33 @@ inline static void printf_double ( double d )
static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
{
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP )
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
fputs ( "( ", stdout );
if ( unit->left )
}
if ( unit->left ) {
rofi_theme_print_distance_unit ( unit->left );
}
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_ADD ) {
fputs ( " + ", stdout );
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_SUBTRACT ) {
}
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_SUBTRACT ) {
fputs ( " - ", stdout );
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_DIVIDE ) {
}
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_DIVIDE ) {
fputs ( " / ", stdout );
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MULTIPLY) {
}
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MULTIPLY ) {
fputs ( " * ", stdout );
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MODULO) {
}
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MODULO ) {
fputs ( " % ", stdout );
}
if ( unit->right )
if ( unit->right ) {
rofi_theme_print_distance_unit ( unit->right );
}
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_NONE )
{
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_NONE ) {
if ( unit->type == ROFI_PU_PX ) {
printf ( "%upx ", (unsigned int) unit->distance );
}
@ -318,9 +322,10 @@ static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
fputs ( "em ", stdout );
}
}
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP )
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
fputs ( " )", stdout );
}
}
static void rofi_theme_print_distance ( RofiDistance d )
{
@ -927,7 +932,6 @@ static int get_pixels ( RofiDistanceUnit *unit, RofiOrientation ori )
{
int val = unit->distance;
if ( unit->type == ROFI_PU_EM ) {
val = unit->distance * textbox_get_estimated_char_height ();
}
@ -952,7 +956,6 @@ static int get_pixels ( RofiDistanceUnit *unit, RofiOrientation ori )
return val;
}
static int distance_unit_get_pixel ( RofiDistanceUnit *unit, RofiOrientation ori )
{
switch ( unit->modtype )
@ -990,7 +993,6 @@ static int distance_unit_get_pixel ( RofiDistanceUnit *unit, RofiOrientation ori
return get_pixels ( unit, ori );
}
int distance_get_pixel ( RofiDistance d, RofiOrientation ori )
{
return distance_unit_get_pixel ( &( d.base ), ori );
@ -1319,7 +1321,6 @@ ThemeMediaType rofi_theme_parse_media_type ( const char *type )
return THEME_MEDIA_TYPE_INVALID;
}
gboolean rofi_theme_has_property ( const widget *widget, const char *property )
{
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );

View file

@ -223,12 +223,12 @@ void rofi_capture_screenshot ( void )
g_date_time_unref ( now );
}
/**
* Code used for benchmarking drawing the gui, this will keep updating the UI as fast as possible.
*/
gboolean do_bench = TRUE;
struct {
struct
{
GTimer *time;
uint64_t draws;
double last_ts;
@ -785,7 +785,8 @@ void __create_window ( MenuFlags menu_flags )
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, dpi );
config.dpi = dpi;
} else {
}
else {
// default pango is 96.
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
config.dpi = pango_cairo_font_map_get_resolution ( (PangoCairoFontMap *) font_map );

View file

@ -231,7 +231,9 @@ static void hori_calculate_size ( box *b )
int left = widget_padding_get_left ( WIDGET ( b ) );
double rem = rem_width - b->max_size;
int index = 0;
if ( rem < 0 ) rem = 0;
if ( rem < 0 ) {
rem = 0;
}
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
widget * child = (widget *) iter->data;
if ( child->enabled == FALSE ) {

View file

@ -181,7 +181,8 @@ static void listview_add_widget ( listview *lv, _listview_row *row, widget *wid,
else if ( strcasecmp ( label, "element-index" ) == 0 ) {
row->index = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
box_add ( (box *) wid, WIDGET ( row->index ), FALSE );
} else {
}
else {
widget *wid2 = (widget *) box_create ( wid, label, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *) wid, WIDGET ( wid2 ), TRUE );
GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
@ -189,7 +190,6 @@ static void listview_add_widget ( listview *lv, _listview_row *row, widget *wid,
listview_add_widget ( lv, row, wid2, (const char *) iter->data );
}
}
}
static void listview_create_row ( listview *lv, _listview_row *row )
@ -663,7 +663,10 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
if ( lv->eh > 1 && row.textbox ) {
char buff[lv->eh * 2 + 1];
memset ( buff, '\0', lv->eh * 2 + 1 );
for ( unsigned int i = 0; i < (lv->eh-1); i++) { buff[i*2] = 'a'; buff[i*2+1] ='\n'; };
for ( unsigned int i = 0; i < ( lv->eh - 1 ); i++ ) {
buff[i * 2] = 'a'; buff[i * 2 + 1] = '\n';
}
;
textbox_text ( row.textbox, buff );
}
lv->element_height = widget_get_desired_height ( WIDGET ( row.box ) );

View file

@ -43,25 +43,29 @@ static void draw_rounded_rect ( cairo_t * d,
if ( r0 > 0 ) {
cairo_move_to ( d, x1, y1 + r0 );
cairo_arc ( d, x1 + r0, y1 + r0, r0, -G_PI, -G_PI_2 );
} else {
}
else {
cairo_move_to ( d, x1, y1 );
}
if ( r1 > 0 ) {
cairo_line_to ( d, x2 - r1, y1 );
cairo_arc ( d, x2 - r1, y1 + r1, r1, -G_PI_2, 0.0 );
} else {
}
else {
cairo_line_to ( d, x2, y1 );
}
if ( r2 > 0 ) {
cairo_line_to ( d, x2, y2 - r2 );
cairo_arc ( d, x2 - r2, y2 - r2, r2, 0.0, G_PI_2 );
} else {
}
else {
cairo_line_to ( d, x2, y2 );
}
if ( r3 > 0 ) {
cairo_line_to ( d, x1 + r3, y2 );
cairo_arc ( d, x1 + r3, y2 - r3, r3, G_PI_2, G_PI );
} else {
}
else {
cairo_line_to ( d, x1, y2 );
}
cairo_close_path ( d );
@ -280,25 +284,29 @@ void widget_draw ( widget *widget, cairo_t *d )
if ( radius_tl > 0 ) {
radius_out_tl = radius_tl + minof_tl,
radius_int_tl = radius_tl - minof_tl;
} else {
}
else {
radius_out_tl = radius_int_tl = 0;
}
if ( radius_tr > 0 ) {
radius_out_tr = radius_tr + minof_tr,
radius_int_tr = radius_tr - minof_tr;
} else {
}
else {
radius_out_tr = radius_int_tr = 0;
}
if ( radius_br > 0 ) {
radius_out_br = radius_br + minof_br,
radius_int_br = radius_br - minof_br;
} else {
}
else {
radius_out_br = radius_int_br = 0;
}
if ( radius_bl > 0 ) {
radius_out_bl = radius_bl + minof_bl,
radius_int_bl = radius_bl - minof_bl;
} else {
}
else {
radius_out_bl = radius_int_bl = 0;
}