diff options
author | Dave Davenport <qball@gmpclient.org> | 2018-08-08 15:55:13 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2018-08-08 15:55:13 +0200 |
commit | 859a9c79d604ab6d0bd25af269e4c3f59b2a970b (patch) | |
tree | 025477f377a28581d2ffea4098b2caa939b64ceb /source | |
parent | 4631ac711f8048433ea9b5a3449179ef3f583cd7 (diff) |
Indent the code.
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/drun.c | 68 | ||||
-rw-r--r-- | source/dialogs/script.c | 19 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 1 | ||||
-rw-r--r-- | source/dialogs/window.c | 7 | ||||
-rw-r--r-- | source/helper.c | 3 | ||||
-rw-r--r-- | source/history.c | 2 | ||||
-rw-r--r-- | source/keyb.c | 14 | ||||
-rw-r--r-- | source/rofi-icon-fetcher.c | 90 | ||||
-rw-r--r-- | source/rofi.c | 9 | ||||
-rw-r--r-- | source/theme.c | 4 | ||||
-rw-r--r-- | source/view.c | 60 | ||||
-rw-r--r-- | source/widgets/box.c | 4 | ||||
-rw-r--r-- | source/widgets/icon.c | 24 | ||||
-rw-r--r-- | source/widgets/widget.c | 79 | ||||
-rw-r--r-- | source/xcb.c | 416 | ||||
-rw-r--r-- | source/xrmoptions.c | 2 |
16 files changed, 396 insertions, 406 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index cecba726..18305ec3 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -59,7 +59,6 @@ char *DRUN_GROUP_NAME = "Desktop Entry"; - typedef struct _DRunModePrivateData DRunModePrivateData; /** * Store extra information about the entry. @@ -67,20 +66,20 @@ typedef struct _DRunModePrivateData DRunModePrivateData; */ typedef struct { - thread_state st; + thread_state st; DRunModePrivateData *pd; /* category */ - char *action; + char *action; /* Root */ - char *root; + char *root; /* Path to desktop file */ - char *path; + char *path; /* Application id (.desktop filename) */ - char *app_id; + char *app_id; /* Desktop id */ - char *desktop_id; + char *desktop_id; /* Icon stuff */ - char *icon_name; + char *icon_name; /* Icon size is used to indicate what size is requested by the gui. * secondary it indicates if the request for a lookup has been issued (0 not issued ) */ @@ -131,18 +130,18 @@ static DRunEntryField matching_entry_fields[DRUN_MATCH_NUM_FIELDS] = { struct _DRunModePrivateData { - DRunModeEntry *entry_list; - unsigned int cmd_list_length; - unsigned int cmd_list_length_actual; + DRunModeEntry *entry_list; + unsigned int cmd_list_length; + unsigned int cmd_list_length_actual; // List of disabled entries. - GHashTable *disabled_entries; - unsigned int disabled_entries_length; - unsigned int expected_line_height; + GHashTable *disabled_entries; + unsigned int disabled_entries_length; + unsigned int expected_line_height; // Theme - const gchar *icon_theme; + const gchar *icon_theme; // DE - gchar **current_desktop_list; + gchar **current_desktop_list; }; struct RegexEvalArg @@ -412,21 +411,21 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c else { 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; pd->entry_list[pd->cmd_list_length].icon_fetch_uid = 0; - pd->entry_list[pd->cmd_list_length].root = g_strdup ( root ); - pd->entry_list[pd->cmd_list_length].path = g_strdup ( path ); - pd->entry_list[pd->cmd_list_length].desktop_id = g_strdup ( id ); - pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) ); + pd->entry_list[pd->cmd_list_length].root = g_strdup ( root ); + pd->entry_list[pd->cmd_list_length].path = g_strdup ( path ); + pd->entry_list[pd->cmd_list_length].desktop_id = g_strdup ( id ); + pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) ); gchar *n = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "Name", NULL, NULL ); - if ( action != DRUN_GROUP_NAME ){ + if ( action != DRUN_GROUP_NAME ) { gchar *na = g_key_file_get_locale_string ( kf, action, "Name", NULL, NULL ); - gchar *l = g_strdup_printf("%s - %s", n, na); - g_free(n); + gchar *l = g_strdup_printf ( "%s - %s", n, na ); + g_free ( n ); n = l; } - pd->entry_list[pd->cmd_list_length].name = n; + pd->entry_list[pd->cmd_list_length].name = n; pd->entry_list[pd->cmd_list_length].action = DRUN_GROUP_NAME; gchar *gn = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "GenericName", NULL, NULL ); pd->entry_list[pd->cmd_list_length].generic_name = gn; @@ -462,14 +461,14 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c if ( !parse_action ) { gsize actions_length = 0; - char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL ); - for ( gsize iter = 0; iter < actions_length; iter++ ){ - char *new_action = g_strdup_printf("Desktop Action %s", actions[iter]); - if (! read_desktop_file ( pd, root, path, basename, new_action ) ){ + char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL ); + for ( gsize iter = 0; iter < actions_length; iter++ ) { + char *new_action = g_strdup_printf ( "Desktop Action %s", actions[iter] ); + if ( !read_desktop_file ( pd, root, path, basename, new_action ) ) { g_free ( new_action ); } } - g_strfreev(actions); + g_strfreev ( actions ); } return TRUE; } @@ -618,7 +617,6 @@ static void get_apps ( DRunModePrivateData *pd ) TICK_N ( "Sorting done." ); } - static void drun_mode_parse_entry_fields () { char *savept = NULL; @@ -660,7 +658,7 @@ static int drun_mode_init ( Mode *sw ) if ( mode_get_private_data ( sw ) != NULL ) { return TRUE; } - DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) ); + DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) ); pd->disabled_entries = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL ); mode_set_private_data ( sw, (void *) pd ); // current destkop @@ -772,8 +770,10 @@ static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line, DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw ); g_return_val_if_fail ( pd->entry_list != NULL, NULL ); DRunModeEntry *dr = &( pd->entry_list[selected_line] ); - if ( dr->icon_name == NULL ) return NULL; - if ( dr->icon_fetch_uid >0){ + if ( dr->icon_name == NULL ) { + return NULL; + } + if ( dr->icon_fetch_uid > 0 ) { return rofi_icon_fetcher_get ( dr->icon_fetch_uid ); } dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->icon_name, height ); diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 0ff1893f..e68e4bc0 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -79,7 +79,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length ) char *value = line + length_key + 1; if ( strcasecmp ( line, "message" ) == 0 ) { g_free ( pd->message ); - pd->message = strlen(value)? g_strdup ( value ):NULL; + pd->message = strlen ( value ) ? g_strdup ( value ) : NULL; } else if ( strcasecmp ( line, "prompt" ) == 0 ) { g_free ( pd->prompt ); @@ -100,11 +100,11 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length ) static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length ) { - int fd = -1; - GError *error = NULL; - char **retv = NULL; - char **argv = NULL; - int argc = 0; + int fd = -1; + GError *error = NULL; + char **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* ) ); @@ -126,7 +126,7 @@ 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; - size_t actual_size = 0; + size_t actual_size = 0; while ( ( read_length = getline ( &buffer, &buffer_length, inp ) ) > 0 ) { // Filter out line-end. if ( buffer[read_length - 1] == '\n' ) { @@ -190,15 +190,14 @@ static unsigned int script_mode_get_num_entries ( const Mode *sw ) static void script_mode_reset_highlight ( Mode *sw ) { - ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; + ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; rmpd->num_urgent_list = 0; g_free ( rmpd->urgent_list ); - rmpd->urgent_list = NULL; + rmpd->urgent_list = NULL; rmpd->num_active_list = 0; g_free ( rmpd->active_list ); rmpd->active_list = NULL; - } static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line ) diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 4f9bb46f..a3d2f84e 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -487,7 +487,6 @@ static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned in return retv; } - /** * @param sw Object handle to the SSH Mode object * @param selected_line The line to view diff --git a/source/dialogs/window.c b/source/dialogs/window.c index d3af47e8..5355c192 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -914,12 +914,11 @@ static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line, c->icon = get_net_wm_icon ( rmpd->ids->array[selected_line], size ); c->icon_checked = TRUE; } - if ( c->icon == NULL && c->class ){ - if ( c->icon_fetch_uid > 0){ + if ( c->icon == NULL && c->class ) { + if ( c->icon_fetch_uid > 0 ) { return rofi_icon_fetcher_get ( c->icon_fetch_uid ); } - c->icon_fetch_uid = rofi_icon_fetcher_query ( c->class, size); - + c->icon_fetch_uid = rofi_icon_fetcher_query ( c->class, size ); } return c->icon; } diff --git a/source/helper.c b/source/helper.c index 52922912..0ca94e47 100644 --- a/source/helper.c +++ b/source/helper.c @@ -587,7 +587,8 @@ int config_sanity_check ( void ) } else if ( g_strcmp0 ( config.sorting_method, "fzf" ) == 0 ) { config.sorting_method_enum = SORT_FZF; - } else { + } + else { g_string_append_printf ( msg, "\t<b>config.sorting_method</b>=%s is not a valid sorting strategy.\nValid options are: normal or fzf.\n", config.sorting_method ); found_error = 1; diff --git a/source/history.c b/source/history.c index 480fdc22..64f73205 100644 --- a/source/history.c +++ b/source/history.c @@ -113,7 +113,7 @@ static char ** __history_get_element_list_fields ( FILE *fd, unsigned int *lengt ( *length )++; } - if ( buffer_length > 0 ){ + if ( buffer_length > 0 ) { g_free ( buffer ); } return retv; diff --git a/source/keyb.c b/source/keyb.c index e230984e..b4603b38 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -112,14 +112,14 @@ ActionBindingEntry rofi_bindings[] = /* Mouse-aware bindings */ - { .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" }, - { .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" }, - { .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" }, - { .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" }, + { .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" }, + { .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" }, + { .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" }, + { .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" }, - { .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" }, - { .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" }, - { .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action" }, + { .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" }, + { .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" }, + { .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action"}, }; /** Default binding of mouse button to action. */ diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 80ba9296..c9e7846c 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -39,36 +39,36 @@ #include "nkutils-xdg-theme.h" -typedef struct { +typedef struct +{ // Context for icon-themes. NkXdgThemeContext *xdg_context; // On name. - GHashTable *icon_cache; + GHashTable *icon_cache; // On uid. - GHashTable *icon_cache_uid; - - uint32_t last_uid; - + GHashTable *icon_cache_uid; + uint32_t last_uid; } IconFetcher; - -typedef struct { - char *name; +typedef struct +{ + char *name; GList *sizes; } IconFetcherNameEntry; -typedef struct { - thread_state state; +typedef struct +{ + thread_state state; - GCond *cond; - GMutex *mutex; - unsigned int *acount; + GCond *cond; + GMutex *mutex; + unsigned int *acount; - uint32_t uid; - int size; - cairo_surface_t *surface; + uint32_t uid; + int size; + cairo_surface_t *surface; IconFetcherNameEntry *entry; } IconFetcherEntry; @@ -78,17 +78,15 @@ typedef struct { */ IconFetcher *rofi_icon_fetcher_data = NULL; - static void rofi_icon_fetch_entry_free ( gpointer data ) { - IconFetcherNameEntry *entry = (IconFetcherNameEntry*) data; + IconFetcherNameEntry *entry = (IconFetcherNameEntry *) data; // Free name/key. g_free ( entry->name ); - for ( GList *iter = g_list_first ( entry->sizes ); iter; iter = g_list_next ( iter ) ) { - IconFetcherEntry *sentry = (IconFetcherEntry *)(iter->data); + IconFetcherEntry *sentry = (IconFetcherEntry *) ( iter->data ); cairo_surface_destroy ( sentry->surface ); g_free ( sentry ); @@ -98,7 +96,6 @@ static void rofi_icon_fetch_entry_free ( gpointer data ) g_free ( entry ); } - void rofi_icon_fetcher_init ( void ) { g_assert ( rofi_icon_fetcher_data == NULL ); @@ -108,26 +105,25 @@ void rofi_icon_fetcher_init ( void ) "gnome", NULL }; - const char *themes[2] = { config.icon_theme, NULL}; + const char *themes[2] = { config.icon_theme, NULL }; - rofi_icon_fetcher_data = g_malloc0(sizeof(IconFetcher)); + rofi_icon_fetcher_data = g_malloc0 ( sizeof ( IconFetcher ) ); rofi_icon_fetcher_data->xdg_context = nk_xdg_theme_context_new ( icon_fallback_themes, NULL ); nk_xdg_theme_preload_themes_icon ( rofi_icon_fetcher_data->xdg_context, themes ); - rofi_icon_fetcher_data->icon_cache_uid = g_hash_table_new ( g_direct_hash, g_direct_equal ); rofi_icon_fetcher_data->icon_cache = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, rofi_icon_fetch_entry_free ); } - void rofi_icon_fetcher_destroy ( void ) { - if ( rofi_icon_fetcher_data == NULL ) return; + if ( rofi_icon_fetcher_data == NULL ) { + return; + } nk_xdg_theme_context_free ( rofi_icon_fetcher_data->xdg_context ); - g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache_uid ); g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache ); @@ -138,14 +134,14 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint g_debug ( "starting up icon fetching thread." ); // as long as dr->icon is updated atomicly.. (is a pointer write atomic?) // this should be fine running in another thread. - IconFetcherEntry *sentry = (IconFetcherEntry*) sdata; - const gchar *themes[] = { + IconFetcherEntry *sentry = (IconFetcherEntry *) sdata; + const gchar *themes[] = { config.icon_theme, NULL }; - const gchar *icon_path; - gchar *icon_path_ = NULL; + const gchar *icon_path; + gchar *icon_path_ = NULL; if ( g_path_is_absolute ( sentry->entry->name ) ) { icon_path = sentry->entry->name; @@ -153,7 +149,7 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint else { icon_path = icon_path_ = nk_xdg_theme_get_icon ( rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name, sentry->size, 1, TRUE ); if ( icon_path_ == NULL ) { - g_debug ( "failed to get icon %s(%d): n/a",sentry->entry->name, sentry->size ); + g_debug ( "failed to get icon %s(%d): n/a", sentry->entry->name, sentry->size ); return; } else{ @@ -177,51 +173,49 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint cairo_surface_destroy ( icon_surf ); icon_surf = NULL; } - sentry->surface= icon_surf; + sentry->surface = icon_surf; } g_free ( icon_path_ ); rofi_view_reload (); } - uint32_t rofi_icon_fetcher_query ( const char *name, const int size ) { - g_debug ("Query: %s(%d)", name, size); + g_debug ( "Query: %s(%d)", name, size ); IconFetcherNameEntry *entry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache, name ); if ( entry == NULL ) { - entry = g_new0(IconFetcherNameEntry,1); - entry->name = g_strdup(name); + entry = g_new0 ( IconFetcherNameEntry, 1 ); + entry->name = g_strdup ( name ); g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache, entry->name, entry ); } IconFetcherEntry *sentry; - for ( GList *iter = g_list_first(entry->sizes); iter; iter = g_list_next ( iter ) ) { + for ( GList *iter = g_list_first ( entry->sizes ); iter; iter = g_list_next ( iter ) ) { sentry = iter->data; - if ( sentry->size == size ){ + if ( sentry->size == size ) { return sentry->uid; } } // Not found. - sentry = g_new0(IconFetcherEntry, 1); - sentry->uid = ++(rofi_icon_fetcher_data->last_uid); - sentry->size = size; - sentry->entry = entry; + sentry = g_new0 ( IconFetcherEntry, 1 ); + sentry->uid = ++( rofi_icon_fetcher_data->last_uid ); + sentry->size = size; + sentry->entry = entry; sentry->surface = NULL; entry->sizes = g_list_prepend ( entry->sizes, sentry ); - g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER(sentry->uid), sentry ); + g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER ( sentry->uid ), sentry ); // Push into fetching queue. sentry->state.callback = rofi_icon_fetcher_worker; - g_thread_pool_push ( tpool, sentry, NULL); + g_thread_pool_push ( tpool, sentry, NULL ); return sentry->uid; } - cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid ) { - IconFetcherEntry *sentry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER(uid) ); + IconFetcherEntry *sentry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER ( uid ) ); if ( sentry ) { return sentry->surface; } diff --git a/source/rofi.c b/source/rofi.c index ad13079b..3d125c5e 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -78,7 +78,7 @@ #include "mode-private.h" /** Location of pidfile for this instance. */ -char *pidfile = NULL; +char *pidfile = NULL; /** Location of Cache directory. */ const char *cache_dir = NULL; @@ -92,7 +92,7 @@ void rofi_add_error_message ( GString *str ) } /** Path to the configuration file */ -G_MODULE_EXPORT char *config_path = NULL; +G_MODULE_EXPORT char *config_path = NULL; /** Path to the configuration file in the new format */ G_MODULE_EXPORT char *config_path_new = NULL; /** Array holding all activated modi. */ @@ -108,7 +108,7 @@ unsigned int num_modi = 0; unsigned int curr_switcher = 0; /** Handle to NkBindings object for input devices. */ -NkBindings *bindings = NULL; +NkBindings *bindings = NULL; /** Glib main loop. */ GMainLoop *main_loop = NULL; @@ -858,7 +858,8 @@ int main ( int argc, char *argv[] ) rofi_theme_free ( rofi_theme ); rofi_theme = NULL; } - } else { + } + else { g_free ( config_path_new ); config_path_new = NULL; config_parse_xresource_options_file ( config_path ); diff --git a/source/theme.c b/source/theme.c index 5b51b8c3..a02344cf 100644 --- a/source/theme.c +++ b/source/theme.c @@ -632,7 +632,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl return p->value.f; } // Fallback to integer if double is not found. - p = rofi_theme_find_property ( wid, P_INTEGER, property, FALSE ); + p = rofi_theme_find_property ( wid, P_INTEGER, property, FALSE ); if ( p ) { if ( p->type == P_INHERIT ) { if ( widget->parent ) { @@ -640,7 +640,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl } return def; } - return (double)p->value.i; + return (double) p->value.i; } g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property ); return def; diff --git a/source/view.c b/source/view.c index 93f4b0e6..d83d72f1 100644 --- a/source/view.c +++ b/source/view.c @@ -126,9 +126,9 @@ struct .fake_bgrel = FALSE, .flags = MENU_NORMAL, .views = G_QUEUE_INIT, - .idle_timeout = 0, - .count = 0L, - .repaint_source = 0, + .idle_timeout = 0, + .count = 0L, + .repaint_source = 0, .fullscreen = FALSE, }; @@ -559,14 +559,14 @@ static RofiViewState * __rofi_view_state_create ( void ) typedef struct _thread_state_view { /** Generic thread state. */ - thread_state st; + thread_state st; /** Condition. */ - GCond *cond; + GCond *cond; /** Lock for condition. */ - GMutex *mutex; + GMutex *mutex; /** Count that is protected by lock. */ - unsigned int *acount; + unsigned int *acount; /** Current state. */ RofiViewState *state; @@ -581,7 +581,6 @@ typedef struct _thread_state_view const char *pattern; /** Length of pattern. */ glong plen; - } thread_state_view; /** * @param data A thread_state object. @@ -597,7 +596,7 @@ static void rofi_view_call_thread ( gpointer data, gpointer user_data ) static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data ) { - thread_state_view *t = (thread_state_view *)ts; + thread_state_view *t = (thread_state_view *) ts; for ( unsigned int i = t->start; i < t->stop; i++ ) { int match = mode_token_match ( t->state->sw, t->state->tokens, i ); // If each token was matched, add it to list. @@ -609,13 +608,13 @@ static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data glong slen = g_utf8_strlen ( str, -1 ); switch ( config.sorting_method_enum ) { - case SORT_FZF: - t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( t->pattern, t->plen, str, slen ); - break; - case SORT_NORMAL: - default: - t->state->distance[i] = levenshtein ( t->pattern, t->plen, str, slen ); - break; + case SORT_FZF: + t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( t->pattern, t->plen, str, slen ); + break; + case SORT_NORMAL: + default: + t->state->distance[i] = levenshtein ( t->pattern, t->plen, str, slen ); + break; } g_free ( str ); } @@ -804,7 +803,8 @@ void __create_window ( MenuFlags menu_flags ) const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL ); if ( transparency ) { rofi_view_setup_fake_transparency ( transparency ); - } else if ( config.fake_transparency && config.fake_background ) { + } + else if ( config.fake_transparency && config.fake_background ) { rofi_view_setup_fake_transparency ( config.fake_background ); } if ( xcb->sncontext != NULL ) { @@ -1051,24 +1051,24 @@ static void rofi_view_refilter ( RofiViewState *state ) * If number of threads > 1 and there are enough (> 1000) items, spawn jobs for the thread pool. * For large lists with 8 threads I see a factor three speedup of the whole function. */ - unsigned int nt = MAX ( 1, state->num_lines / 500 ); + unsigned int nt = MAX ( 1, state->num_lines / 500 ); thread_state_view states[nt]; - GCond cond; - GMutex mutex; + GCond cond; + GMutex mutex; g_mutex_init ( &mutex ); g_cond_init ( &cond ); unsigned int count = nt; unsigned int steps = ( state->num_lines + nt ) / nt; for ( unsigned int i = 0; i < nt; i++ ) { - states[i].state = state; - states[i].start = i * steps; - states[i].stop = MIN ( state->num_lines, ( i + 1 ) * steps ); - states[i].count = 0; - states[i].cond = &cond; - states[i].mutex = &mutex; - states[i].acount = &count; - states[i].plen = plen; - states[i].pattern = pattern; + states[i].state = state; + states[i].start = i * steps; + states[i].stop = MIN ( state->num_lines, ( i + 1 ) * steps ); + states[i].count = 0; + states[i].cond = &cond; + states[i].mutex = &mutex; + states[i].acount = &count; + states[i].plen = plen; + states[i].pattern = pattern; states[i].st.callback = filter_elements; if ( i > 0 ) { g_thread_pool_push ( tpool, &states[i], NULL ); @@ -1668,7 +1668,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, box_add ( (box *) parent_widget, WIDGET ( t ), TRUE ); } else if ( g_ascii_strncasecmp ( name, "icon", 4 ) == 0 ) { - icon *t = icon_create ( parent_widget, name ); + icon *t = icon_create ( parent_widget, name ); box_add ( (box *) parent_widget, WIDGET ( t ), TRUE ); } else { diff --git a/source/widgets/box.c b/source/widgets/box.c index 7c184d72..11733a6f 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -58,10 +58,10 @@ static int box_get_desired_width ( widget *wid ) int width = 0; // Allow user to override. - RofiDistance w = rofi_theme_get_distance ( wid, "width", 0 ); + RofiDistance w = rofi_theme_get_distance ( wid, "width", 0 ); width = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL ); if ( width > 0 ) { - return width ; + return width; } if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) { diff --git a/source/widgets/icon.c b/source/widgets/icon.c index 04782edd..83e47681 100644 --- a/source/widgets/icon.c +++ b/source/widgets/icon.c @@ -39,29 +39,28 @@ struct _icon { - widget widget; + widget widget; // Size of the icon. - int size; + int size; - uint32_t icon_fetch_id; + uint32_t icon_fetch_id; // Source surface. - cairo_surface_t *icon; + cairo_surface_t *icon; }; - static int icon_get_desired_height ( widget *widget ) { icon *b = (icon *) widget; - int height = b->size; + int height = b->size; height += widget_padding_get_padding_height ( widget ); return height; } static int icon_get_desired_width ( widget *widget ) { - icon *b = (icon *) widget; - int width = b->size; + icon *b = (icon *) widget; + int width = b->size; width += widget_padding_get_padding_width ( widget ); return width; } @@ -71,7 +70,6 @@ static void icon_draw ( widget *wid, cairo_t *draw ) icon *b = (icon *) wid; // If no icon is loaded. quit. if ( b->icon == NULL && b->icon_fetch_id > 0 ) { - b->icon = rofi_icon_fetcher_get ( b->icon_fetch_id ); if ( b->icon ) { cairo_surface_reference ( b->icon ); @@ -83,7 +81,7 @@ static void icon_draw ( widget *wid, cairo_t *draw ) int iconh = cairo_image_surface_get_height ( b->icon ); int iconw = cairo_image_surface_get_width ( b->icon ); int icons = MAX ( iconh, iconw ); - double scale = (double) b->size/ icons; + double scale = (double) b->size / icons; |