diff options
author | Dave Davenport <qball@gmpclient.org> | 2020-02-02 13:56:37 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2020-02-02 13:56:37 +0100 |
commit | b1692899969b89b8478e403957e266437e07d9e9 (patch) | |
tree | 0b2a7665e151e3ffe2f8ce8c32f2e3ad2f0aac91 /source | |
parent | 83c2e467d5b34f9e74e2c55b1e9df2b715be175e (diff) |
Indent all the code.
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/dmenu.c | 60 | ||||
-rw-r--r-- | source/dialogs/drun.c | 213 | ||||
-rw-r--r-- | source/dialogs/script.c | 78 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 132 | ||||
-rw-r--r-- | source/dialogs/window.c | 6 | ||||
-rw-r--r-- | source/helper.c | 46 | ||||
-rw-r--r-- | source/keyb.c | 2 | ||||
-rw-r--r-- | source/rofi.c | 46 | ||||
-rw-r--r-- | source/theme.c | 428 | ||||
-rw-r--r-- | source/timings.c | 9 | ||||
-rw-r--r-- | source/view.c | 108 | ||||
-rw-r--r-- | source/widgets/icon.c | 16 | ||||
-rw-r--r-- | source/widgets/listview.c | 136 | ||||
-rw-r--r-- | source/widgets/textbox.c | 25 | ||||
-rw-r--r-- | source/widgets/widget.c | 2 | ||||
-rw-r--r-- | source/xcb.c | 68 | ||||
-rw-r--r-- | source/xrmoptions.c | 164 |
17 files changed, 773 insertions, 766 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 96eddf57..eeef4dba 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -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 ); @@ -90,7 +89,7 @@ typedef struct unsigned int num_selected_list; unsigned int do_markup; // List with entries. - DmenuScriptEntry *cmd_list; + DmenuScriptEntry *cmd_list; unsigned int cmd_list_real_length; unsigned int cmd_list_length; unsigned int only_selected; @@ -123,14 +122,14 @@ static void read_add ( DmenuModePrivateData * pd, char *data, gsize len ) pd->cmd_list[pd->cmd_list_length].icon_fetch_uid = 0; pd->cmd_list[pd->cmd_list_length].icon_name = NULL; pd->cmd_list[pd->cmd_list_length].meta = NULL; - char *end = strchr(data, '\0'); + char *end = strchr ( data, '\0' ); if ( end != NULL ) { - data_len = end-data; - dmenuscript_parse_entry_extras ( NULL, &(pd->cmd_list[pd->cmd_list_length]), end+1, len-data_len); + data_len = end - data; + dmenuscript_parse_entry_extras ( NULL, &( pd->cmd_list[pd->cmd_list_length] ), end + 1, len - data_len ); } char *utfstr = rofi_force_utf8 ( data, data_len ); - pd->cmd_list[pd->cmd_list_length].entry = utfstr; - pd->cmd_list[pd->cmd_list_length + 1].entry = NULL; + pd->cmd_list[pd->cmd_list_length].entry = utfstr; + pd->cmd_list[pd->cmd_list_length + 1].entry = NULL; pd->cmd_list_length++; } @@ -250,17 +249,21 @@ 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; } static char *get_display_data ( const Mode *data, unsigned int index, int *state, G_GNUC_UNUSED GList **list, int get_entry ) { - Mode *sw = (Mode *) data; - DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw ); - DmenuScriptEntry *retv = (DmenuScriptEntry *) pd->cmd_list; + Mode *sw = (Mode *) data; + DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw ); + DmenuScriptEntry *retv = (DmenuScriptEntry *) pd->cmd_list; for ( unsigned int i = 0; i < pd->num_active_list; i++ ) { unsigned int start = get_index ( pd->cmd_list_length, pd->active_list[i].start ); unsigned int stop = get_index ( pd->cmd_list_length, pd->active_list[i].stop ); @@ -433,18 +436,18 @@ static int dmenu_mode_init ( Mode *sw ) static int dmenu_token_match ( const Mode *sw, rofi_int_matcher **tokens, unsigned int index ) { DmenuModePrivateData *rmpd = (DmenuModePrivateData *) mode_get_private_data ( sw ); - if ( rmpd->do_markup) { + if ( rmpd->do_markup ) { /** Strip out the markup when matching. */ char *esc = NULL; - pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL, NULL); + pango_parse_markup ( rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL, NULL ); if ( esc ) { - int retv = helper_token_match ( tokens, esc); - g_free (esc); + int retv = helper_token_match ( tokens, esc ); + g_free ( esc ); return retv; } return FALSE; - - } else { + } + else { return helper_token_match ( tokens, rmpd->cmd_list[index].entry ); } } @@ -460,7 +463,7 @@ static cairo_surface_t *dmenu_get_icon ( const Mode *sw, unsigned int selected_l { DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw ); g_return_val_if_fail ( pd->cmd_list != NULL, NULL ); - DmenuScriptEntry *dr = &( pd->cmd_list[selected_line] ); + DmenuScriptEntry *dr = &( pd->cmd_list[selected_line] ); if ( dr->icon_name == NULL ) { return NULL; } @@ -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 ) { @@ -491,19 +493,19 @@ static void dmenu_finish ( RofiViewState *state, int retv ) static void dmenu_print_results ( DmenuModePrivateData *pd, const char *input ) { DmenuScriptEntry *cmd_list = pd->cmd_list; - int seen = FALSE; + int seen = FALSE; if ( pd->selected_list != NULL ) { for ( unsigned int st = 0; st < pd->cmd_list_length; st++ ) { if ( bitget ( pd->selected_list, st ) ) { seen = TRUE; - rofi_output_formatted_line ( pd->format, cmd_list[st].entry , st, input ); + rofi_output_formatted_line ( pd->format, cmd_list[st].entry, st, input ); } } } if ( !seen ) { const char *cmd = input; if ( pd->selected_line != UINT32_MAX ) { - cmd = cmd_list[pd->selected_line].entry ; + cmd = cmd_list[pd->selected_line].entry; } rofi_output_formatted_line ( pd->format, cmd, pd->selected_line, input ); } @@ -514,7 +516,7 @@ static void dmenu_finalize ( RofiViewState *state ) int retv = FALSE; DmenuModePrivateData *pd = (DmenuModePrivateData *) rofi_view_get_mode ( state )->private_data; unsigned int cmd_list_length = pd->cmd_list_length; - DmenuScriptEntry *cmd_list = pd->cmd_list; + DmenuScriptEntry *cmd_list = pd->cmd_list; char *input = g_strdup ( rofi_view_get_user_input ( state ) ); pd->selected_line = rofi_view_get_selected_line ( state );; @@ -647,9 +649,9 @@ int dmenu_switcher_dialog ( void ) get_dmenu_sync ( pd ); } } - char *input = NULL; - unsigned int cmd_list_length = pd->cmd_list_length; - DmenuScriptEntry *cmd_list = pd->cmd_list; + char *input = NULL; + unsigned int cmd_list_length = pd->cmd_list_length; + DmenuScriptEntry *cmd_list = pd->cmd_list; pd->only_selected = FALSE; pd->multi_select = FALSE; @@ -667,7 +669,7 @@ int dmenu_switcher_dialog ( void ) } } if ( config.auto_select && cmd_list_length == 1 ) { - rofi_output_formatted_line ( pd->format, cmd_list[0].entry , 0, config.filter ); + rofi_output_formatted_line ( pd->format, cmd_list[0].entry, 0, config.filter ); return TRUE; } if ( find_arg ( "-password" ) >= 0 ) { @@ -694,7 +696,7 @@ int dmenu_switcher_dialog ( void ) unsigned int i = 0; for ( i = 0; i < cmd_list_length; i++ ) { if ( tokens == NULL || helper_token_match ( tokens, cmd_list[i].entry ) ) { - rofi_output_formatted_line ( pd->format, cmd_list[i].entry , i, config.filter ); + rofi_output_formatted_line ( pd->format, cmd_list[i].entry, i, config.filter ); } } helper_tokenize_free ( tokens ); diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 943741b0..0a0d7ff2 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -55,7 +55,7 @@ #include "rofi-icon-fetcher.h" -#define DRUN_CACHE_FILE "rofi3.druncache" +#define DRUN_CACHE_FILE "rofi3.druncache" #define DRUN_DESKTOP_CACHE_FILE "rofi-drun-desktop.cache" char *DRUN_GROUP_NAME = "Desktop Entry"; @@ -142,8 +142,7 @@ struct _DRunModePrivateData unsigned int disabled_entries_length; unsigned int expected_line_height; - - char **show_categories; + char **show_categories; // Theme const gchar *icon_theme; @@ -234,11 +233,10 @@ static void exec_cmd_entry ( DRunModeEntry *e ) } if ( e->key_file == NULL ) { - GKeyFile *kf = g_key_file_new (); + 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,11 +280,10 @@ 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++ ){ - for ( int j = 0; field[j] ; j++ ){ + for ( int i = 0; categories && categories[i]; i++ ) { + for ( int j = 0; field[j]; j++ ) { if ( g_str_equal ( categories[i], field[j] ) ) { return TRUE; } @@ -314,7 +311,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const // Check if item is on disabled list. if ( g_hash_table_contains ( pd->disabled_entries, id ) && !parse_action ) { g_debug ( "[%s] [%s] Skipping, was previously seen.", id, path ); - return ; + return; } GKeyFile *kf = g_key_file_new (); GError *error = NULL; @@ -324,14 +321,14 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const g_debug ( "[%s] [%s] Failed to parse desktop file because: %s.", id, path, error->message ); g_error_free ( error ); g_key_file_free ( kf ); - return ; + return; } if ( g_key_file_has_group ( kf, action ) == FALSE ) { // No type? ignore. g_debug ( "[%s] [%s] Invalid desktop file: No %s group", id, path, action ); g_key_file_free ( kf ); - return ; + return; } // Skip non Application entries. gchar *key = g_key_file_get_string ( kf, DRUN_GROUP_NAME, "Type", NULL ); @@ -339,13 +336,13 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const // No type? ignore. g_debug ( "[%s] [%s] Invalid desktop file: No type indicated", id, path ); g_key_file_free ( kf ); - return ; + return; } if ( g_strcmp0 ( key, "Application" ) ) { g_debug ( "[%s] [%s] Skipping desktop file: Not of type application (%s)", id, path, key ); g_free ( key ); g_key_file_free ( kf ); - return ; + return; } g_free ( key ); @@ -353,7 +350,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const if ( !g_key_file_has_key ( kf, DRUN_GROUP_NAME, "Name", NULL ) ) { g_debug ( "[%s] [%s] Invalid desktop file: no 'Name' key present.", id, path ); g_key_file_free ( kf ); - return ; + return; } // Skip hidden entries. @@ -361,7 +358,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const g_debug ( "[%s] [%s] Adding desktop file to disabled list: 'Hidden' key is true", id, path ); g_key_file_free ( kf ); g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) ); - return ; + return; } if ( pd->current_desktop_list ) { gboolean show = TRUE; @@ -396,7 +393,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const g_debug ( "[%s] [%s] Adding desktop file to disabled list: 'OnlyShowIn'/'NotShowIn' keys don't match current desktop", id, path ); g_key_file_free ( kf ); g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) ); - return ; + return; } } // Skip entries that have NoDisplay set. @@ -404,13 +401,13 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const g_debug ( "[%s] [%s] Adding desktop file to disabled list: 'NoDisplay' key is true", id, path ); g_key_file_free ( kf ); g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) ); - return ; + return; } // We need Exec, don't support DBusActivatable if ( !g_key_file_has_key ( kf, DRUN_GROUP_NAME, "Exec", NULL ) ) { g_debug ( "[%s] [%s] Unsupported desktop file: no 'Exec' key present.", id, path ); g_key_file_free ( kf ); - return ; + return; } if ( g_key_file_has_key ( kf, DRUN_GROUP_NAME, "TryExec", NULL ) ) { @@ -420,7 +417,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const if ( fp == NULL ) { g_free ( te ); g_key_file_free ( kf ); - return ; + return; } g_free ( fp ); } @@ -428,7 +425,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const if ( g_file_test ( te, G_FILE_TEST_IS_EXECUTABLE ) == FALSE ) { g_free ( te ); g_key_file_free ( kf ); - return ; + return; } } g_free ( te ); @@ -437,10 +434,10 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const char **categories = NULL; if ( pd->show_categories ) { categories = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Categories", NULL, NULL, NULL ); - if ( !rofi_strv_contains( (const char * const *)categories, (const char *const *)pd->show_categories ) ){ - g_strfreev(categories); + if ( !rofi_strv_contains ( (const char * const *) categories, (const char *const *) pd->show_categories ) ) { + g_strfreev ( categories ); g_key_file_free ( kf ); - return ; + return; } } @@ -478,23 +475,25 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const pd->entry_list[pd->cmd_list_length].generic_name = gn; 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 { + pd->entry_list[pd->cmd_list_length].keywords = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Keywords", NULL, NULL, NULL ); + } + else { pd->entry_list[pd->cmd_list_length].keywords = NULL; } if ( matching_entry_fields[DRUN_MATCH_FIELD_CATEGORIES].enabled ) { if ( categories ) { pd->entry_list[pd->cmd_list_length].categories = categories; - categories = NULL; - } else { + categories = NULL; + } + else { pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Categories", NULL, NULL, NULL ); } } else { pd->entry_list[pd->cmd_list_length].categories = NULL; } - g_strfreev(categories); + g_strfreev ( categories ); pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, action, "Exec", NULL ); @@ -530,7 +529,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const } g_strfreev ( actions ); } - return ; + return; } /** @@ -641,86 +640,88 @@ 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; } } /******************************************* - * Cache voodoo * - *******************************************/ +* Cache voodoo * +*******************************************/ -#define CACHE_VERSION 1 +#define CACHE_VERSION 1 static void drun_write_str ( FILE *fd, const char *str ) { - size_t l = (str == NULL? 0 : strlen(str)); - fwrite ( &l, sizeof(l),1, fd ); + size_t l = ( str == NULL ? 0 : strlen ( str ) ); + fwrite ( &l, sizeof ( l ), 1, fd ); // Only write string if it is not NULL or empty. if ( l > 0 ) { // Also writeout terminating '\0' - fwrite ( str, 1, l+1, fd ); + fwrite ( str, 1, l + 1, fd ); } } static void drun_read_string ( FILE *fd, char **str ) { size_t l = 0; - if ( fread ( &l, sizeof(l), 1, fd ) != 1 ){ - g_warning( "Failed to read entry, cache corrupt?" ); + if ( fread ( &l, sizeof ( l ), 1, fd ) != 1 ) { + g_warning ( "Failed to read entry, cache corrupt?" ); return; } - (*str) = NULL; + ( *str ) = NULL; if ( l > 0 ) { // Include \0 l++; - (*str) = g_malloc(l); - if ( fread ( (*str), 1, l, fd ) != l ){ - g_warning( "Failed to read entry, cache corrupt?" ); + ( *str ) = g_malloc ( l ); + if ( fread ( ( *str ), 1, l, fd ) != l ) { + g_warning ( "Failed to read entry, cache corrupt?" ); } } } static void drun_write_strv ( FILE *fd, char **str ) { - guint vl = (str == NULL? 0 : g_strv_length ( str )); - fwrite ( &vl, sizeof(vl),1, fd ); - for ( guint index = 0; index < vl ; index++ ) { + guint vl = ( str == NULL ? 0 : g_strv_length ( str ) ); + fwrite ( &vl, sizeof ( vl ), 1, fd ); + for ( guint index = 0; index < vl; index++ ) { drun_write_str ( fd, str[index] ); } } static void drun_read_stringv ( FILE *fd, char ***str ) { guint vl = 0; - (*str) = NULL; - if ( fread ( &vl, sizeof(vl), 1, fd ) != 1 ){ - g_warning( "Failed to read entry, cache corrupt?" ); + ( *str ) = NULL; + if ( fread ( &vl, sizeof ( vl ), 1, fd ) != 1 ) { + g_warning ( "Failed to read entry, cache corrupt?" ); return; } - if ( vl > 0 ){ + if ( vl > 0 ) { // Include terminating NULL entry. - (*str) = g_malloc0((vl+1)*sizeof(**str)); + ( *str ) = g_malloc0 ( ( vl + 1 ) * sizeof ( **str ) ); for ( guint index = 0; index < vl; index++ ) { - drun_read_string ( fd, &((*str)[index])); + drun_read_string ( fd, &( ( *str )[index] ) ); } } } 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" ); - if ( fd == NULL ){ + if ( fd == NULL ) { g_warning ( "Failed to write to cache file" ); return; } uint8_t version = CACHE_VERSION; - fwrite ( &version, sizeof(version),1, fd ); + 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 ++ ) - { - DRunModeEntry *entry = & ( pd->entry_list[index] ); + fwrite ( &( pd->cmd_list_length ), sizeof ( pd->cmd_list_length ), 1, fd ); + for ( unsigned int index = 0; index < pd->cmd_list_length; index++ ) { + DRunModeEntry *entry = &( pd->entry_list[index] ); drun_write_str ( fd, entry->action ); drun_write_str ( fd, entry->root ); @@ -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) ; + 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" ); @@ -779,7 +779,7 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil return FALSE; } - if ( fread ( &(pd->cmd_list_length), sizeof(pd->cmd_list_length),1,fd ) != 1 ){ + if ( fread ( &( pd->cmd_list_length ), sizeof ( pd->cmd_list_length ), 1, fd ) != 1 ) { fclose ( fd ); g_warning ( "Cache corrupt, ignoring." ); TICK_N ( "DRUN Read CACHE: stop" ); @@ -788,29 +788,27 @@ static gboolean drun_read_cache ( DRunModePrivateData *pd, const char *cache_fil // set actual length to length; pd->cmd_list_length_actual = pd->cmd_list_length; - pd->entry_list = g_malloc0 ( pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) )); + 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++ ) - { - DRunModeEntry *entry = & ( pd->entry_list[index] ); + for ( unsigned int index = 0; index < pd->cmd_list_length; index++ ) { + DRunModeEntry *entry = &( pd->entry_list[index] ); - drun_read_string ( fd, &(entry->action) ); - drun_read_string ( fd, &(entry->root) ); - drun_read_string ( fd, &(entry->path) ); - drun_read_string ( fd, &(entry->app_id) ); - drun_read_string ( fd, &(entry->desktop_id) ); - drun_read_string ( fd, &(entry->icon_name) ); - drun_read_string ( fd, &(entry->exec) ); - drun_read_string ( fd, &(entry->name) ); - drun_read_string ( fd, &(entry->generic_name) ); + drun_read_string ( fd, &( entry->action ) ); + drun_read_string ( fd, &( entry->root ) ); + drun_read_string ( fd, &( entry->path ) ); + drun_read_string ( fd, &( entry->app_id ) ); + drun_read_string ( fd, &( entry->desktop_id ) ); + drun_read_string ( fd, &( entry->icon_name ) ); + drun_read_string ( fd, &( entry->exec ) ); + drun_read_string ( fd, &( entry->name ) ); + drun_read_string ( fd, &( entry->generic_name ) ); - drun_read_stringv ( fd, &(entry->categories) ); - drun_read_stringv ( fd, &(entry->keywords) ); + drun_read_stringv ( fd, &( entry->categories ) ); + drun_read_stringv ( fd, &( entry->keywords ) ); - drun_read_string ( fd, &(entry->comment) ); + 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 ); @@ -906,8 +902,8 @@ static int drun_mode_init ( Mode *sw ) const char *current_desktop = g_getenv ( "XDG_CURRENT_DESKTOP" ); pd->current_desktop_list = current_desktop ? g_strsplit ( current_desktop, ":", 0 ) : NULL; - if ( config.drun_categories && *(config.drun_categories) ){ - pd->show_categories = g_strsplit(config.drun_categories, ",",0); + if ( config.drun_categories && *( config.drun_categories ) ) { + pd->show_categories = g_strsplit ( config.drun_categories, ",", 0 ); } drun_mode_parse_entry_fields (); @@ -1000,27 +996,27 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in return g_strdup ( "Failed" ); } /* Free temp storage. */ - DRunModeEntry *dr = &( pd->entry_list[selected_line] ); - gchar *cats = NULL; - if ( dr->categories ){ - char *tcats = g_strjoinv(",", dr->categories); + DRunModeEntry *dr = &( pd->entry_list[selected_line] ); + gchar *cats = NULL; + if ( dr->categories ) { + char *tcats = g_strjoinv ( ",", dr->categories ); if ( tcats ) { cats = g_markup_escape_text ( tcats, -1 ); - g_free (tcats); + g_free ( tcats ); } } - gchar *keywords= NULL; - if ( dr->keywords ){ - char *tkeyw= g_strjoinv(",", dr->keywords); + gchar *keywords = NULL; + if ( dr->keywords ) { + char *tkeyw = g_strjoinv ( ",", dr->keywords ); if ( tkeyw ) { keywords = g_markup_escape_text ( tkeyw, -1 ); - g_free (tkeyw); + g_free ( tkeyw ); } } // Needed for display. char *egn = NULL; - char *en = NULL; - char *ec = NULL; + char *en = NULL; + char *ec = NULL; if ( dr->generic_name ) { egn = g_markup_escape_text ( dr->generic_name, -1 ); } @@ -1028,22 +1024,21 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in en = g_markup_escape_text ( dr->name, -1 ); } if ( dr->comment ) { - ec = g_markup_escape_text ( dr->comment , -1 ); + ec = g_markup_escape_text ( dr->comment, -1 ); } - char *retv = helper_string_replace_if_exists ( config.drun_display_format, - "{generic}", egn, - "{name}", en, - "{comment}", ec, - "{exec}", dr->exec, - "{categories}", cats, - "{keywords}", keywords, - NULL); + "{generic}", egn, + "{name}", en, + "{comment}", ec, + "{exec}", dr->exec, + "{categories}", cats, + "{keywords}", keywords, + NULL ); g_free ( egn ); g_free ( en ); g_free ( ec ); - g_free(cats); + g_free ( cats ); return retv; } diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 514e43ba..254fab0b 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -45,18 +45,16 @@ #include "mode-private.h" - #include "rofi-icon-fetcher.h" #include "dialogs/dmenuscriptshared.h" - typedef struct { /** ID of the current script. */ unsigned int id; /** List of visible items. */ - DmenuScriptEntry *cmd_list; + DmenuScriptEntry *cmd_list; /** length list of visible items. */ unsigned int cmd_list_length; @@ -77,18 +75,18 @@ typedef struct */ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *entry, char *buffer, size_t length ) { - size_t length_key = 0;//strlen ( line ); + size_t length_key = 0; //strlen ( line ); while ( length_key <= length && buffer[length_key] != '\x1f' ) { length_key++; } if ( length_key < length ) { buffer[length_key] = '\0'; char *value = buffer + length_key + 1; - if ( strcasecmp(buffer, "icon" ) == 0 ) { - entry->icon_name = g_strdup(value); + if ( strcasecmp ( buffer, "icon" ) == 0 ) { + entry->icon_name = g_strdup ( value ); } - if ( strcasecmp(buffer, "meta" ) == 0 ) { - entry->meta = g_strdup(value); + if ( strcasecmp ( buffer, "meta" ) == 0 ) { + entry->meta = g_strdup ( value ); } } } @@ -131,11 +129,11 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length ) static DmenuScriptEntry *get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length ) { - int fd = -1; - GError *error = NULL; - DmenuScriptEntry *retv = NULL; - char **argv = NULL; - int argc = 0; + int fd = -1; + GError *error = NULL; + DmenuScriptEntry *retv = NULL; + char **argv = NULL; + int argc = 0; *length = 0; if ( g_shell_parse_argv ( command, &argc, &argv, &error ) ) { argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) ); @@ -171,13 +169,13 @@ static DmenuScriptEntry *get_script_output ( Mode *sw, char *command, char *arg, actual_size += 256; retv = g_realloc ( retv, ( actual_size ) * sizeof ( DmenuScriptEntry ) ); } - size_t buf_length = strlen(buffer)+1; - retv[( *length )].entry = g_memdup ( buffer, buf_length); - retv[( *length )].icon_name = NULL; - retv[( *length )].meta = NULL; - retv[(*length)].icon_fetch_uid = 0; - if ( buf_length > 0 && (read_length > (ssize_t)buf_length) ) { - dmenuscript_parse_entry_extras ( sw, &(retv[(*length)]), buffer+buf_length, read_length-buf_length); + size_t buf_length = strlen ( buffer ) + 1; + retv[( *length )].entry = g_memdup ( buffer, buf_length ); + retv[( *length )].icon_name = NULL; + retv[( *length )].meta = NULL; + retv[( *length )].icon_fetch_uid = 0; + if ( buf_length > 0 && ( read_length > (ssize_t) buf_length ) ) { + dmenuscript_parse_entry_extras ( sw, &( retv[( *length )] ), buffer + buf_length, read_length - buf_length ); } retv[( *length ) + 1].entry = NULL; ( *length )++; @@ -242,7 +240,7 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned { ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; ModeMode retv = MODE_EXIT; - DmenuScriptEntry *new_list = NULL; + DmenuScriptEntry *new_list = NULL; unsigned int new_length = 0; if ( ( mretv & MENU_NEXT ) ) { @@ -265,7 +263,7 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned // If a new list was generated, use that an loop around. if ( new_list != NULL ) { - for ( unsigned int i = 0; i < rmpd->cmd_list_length; i++ ){ + for ( unsigned int i = 0; i < |