diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-06-03 20:35:50 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-06-03 20:35:50 +0200 |
commit | 9a62bfd17284a424cafd4ce649076127eafc2f5d (patch) | |
tree | b2c89cc4ba6917388aafd2f050f9ec55f723f4db /source | |
parent | 684211aba4353a15436533d5782dc02e00c3f72e (diff) |
Run indenter.
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/drun.c | 56 | ||||
-rw-r--r-- | source/dialogs/run.c | 2 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 2 | ||||
-rw-r--r-- | source/helper.c | 6 | ||||
-rw-r--r-- | source/rofi.c | 4 | ||||
-rw-r--r-- | source/theme.c | 24 | ||||
-rw-r--r-- | source/view.c | 109 | ||||
-rw-r--r-- | source/widgets/box.c | 19 | ||||
-rw-r--r-- | source/widgets/listview.c | 131 | ||||
-rw-r--r-- | source/widgets/textbox.c | 81 | ||||
-rw-r--r-- | source/xcb.c | 10 |
11 files changed, 222 insertions, 222 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 12c37185..707bfdc3 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -54,7 +54,6 @@ #define DRUN_CACHE_FILE "rofi2.druncache" - /** * Store extra information about the entry. * Currently the executable and if it should run in terminal. @@ -62,13 +61,13 @@ typedef struct { /* Root */ - char *root; + char *root; /* Path to desktop file */ - char *path; + char *path; /* Application id (.desktop filename) */ - char *app_id; + char *app_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 ) */ @@ -97,12 +96,12 @@ typedef struct GHashTable *disabled_entries; unsigned int disabled_entries_length; GThread *thread; - GAsyncQueue *icon_fetch_queue; + GAsyncQueue *icon_fetch_queue; unsigned int expected_line_height; - DRunModeEntry quit_entry; + DRunModeEntry quit_entry; // Theme - const gchar *icon_theme; + const gchar *icon_theme; } DRunModePrivateData; struct RegexEvalArg @@ -194,12 +193,12 @@ static void exec_cmd_entry ( DRunModeEntry *e ) } RofiHelperExecuteContext context = { - .name = e->name, - .icon = e->icon_name, + .name = e->name, + .icon = e->icon_name, .app_id = e->app_id, }; - gboolean sn = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "StartupNotify", NULL ); - gchar *wmclass = NULL; + gboolean sn = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "StartupNotify", NULL ); + gchar *wmclass = NULL; if ( sn && g_key_file_has_key ( e->key_file, "Desktop Entry", "StartupWMClass", NULL ) ) { context.wmclass = wmclass = g_key_file_get_string ( e->key_file, "Desktop Entry", "StartupWMClass", NULL ); } @@ -298,15 +297,15 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c pd->entry_list = g_realloc ( pd->entry_list, pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) ); } pd->entry_list[pd->cmd_list_length].icon_size = 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].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].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) ); gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL ); pd->entry_list[pd->cmd_list_length].name = n; gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL ); pd->entry_list[pd->cmd_list_length].generic_name = gn; - pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL ); - pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL ); + pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL ); + pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL ); if ( config.show_icons ) { pd->entry_list[pd->cmd_list_length].icon_name = g_key_file_get_locale_string ( kf, "Desktop Entry", "Icon", NULL, NULL ); @@ -435,16 +434,16 @@ static void get_apps ( DRunModePrivateData *pd ) TICK_N ( "Get Desktop apps (user dir)" ); // Then read thee system data dirs. const gchar * const * sys = g_get_system_data_dirs (); - for (const gchar * const *iter = sys ; *iter != NULL; ++iter ) { + for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) { gboolean unique = TRUE; // Stupid duplicate detection, better then walking dir. - for ( const gchar *const *iterd = sys ; iterd != iter; ++iterd ){ + for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) { if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { unique = FALSE; } } // Check, we seem to be getting empty string... - if ( unique && (**iter) != '\0') { + if ( unique && ( **iter ) != '\0' ) { dir = g_build_filename ( *iter, "applications", NULL ); walk_dir ( pd, dir, dir ); g_free ( dir ); @@ -459,9 +458,8 @@ static gpointer drun_icon_fetch ( gpointer data ) // as long as dr->icon is updated atomicly.. (is a pointer write atomic?) // this should be fine running in another thread. DRunModePrivateData *pd = (DRunModePrivateData *) data; - DRunModeEntry *dr; - while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue )) != &(pd->quit_entry) ) - { + DRunModeEntry *dr; + while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue ) ) != &( pd->quit_entry ) ) { if ( dr->icon_name == NULL ) { continue; } @@ -478,7 +476,7 @@ static gpointer drun_icon_fetch ( gpointer data ) icon_surf = cairo_image_surface_create_from_png ( icon_path ); } else if ( g_str_has_suffix ( icon_path, ".svg" ) ) { - icon_surf = cairo_image_surface_create_from_svg ( icon_path, dr->icon_size); + icon_surf = cairo_image_surface_create_from_svg ( icon_path, dr->icon_size ); } else { g_debug ( "Icon type not yet supported: %s", icon_path ); @@ -488,7 +486,7 @@ static gpointer drun_icon_fetch ( gpointer data ) if ( cairo_surface_status ( icon_surf ) != CAIRO_STATUS_SUCCESS ) { g_debug ( "Icon failed to open: %s(%d): %s", dr->icon_name, dr->icon_size, icon_path ); cairo_surface_destroy ( icon_surf ); - icon_surf = NULL; + icon_surf = NULL; } dr->icon = icon_surf; } @@ -556,7 +554,7 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i if ( rmpd->thread ) { g_async_queue_lock ( rmpd->icon_fetch_queue ); DRunModeEntry *dr; - while ( (dr = g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue )) != NULL ){ + while ( ( dr = g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) ) != NULL ) { // Reset for possible re-fetch. dr->icon_size = 0; } @@ -578,9 +576,11 @@ static void drun_mode_destroy ( Mode *sw ) if ( rmpd != NULL ) { if ( rmpd->thread ) { g_async_queue_lock ( rmpd->icon_fetch_queue ); - while ( g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) ); + while ( g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) ) { + ; + } // Make the thread quit. - g_async_queue_push_unlocked ( rmpd->icon_fetch_queue, (gpointer) &(rmpd->quit_entry)); + g_async_queue_push_unlocked ( rmpd->icon_fetch_queue, ( gpointer ) & ( rmpd->quit_entry ) ); g_async_queue_unlock ( rmpd->icon_fetch_queue ); g_thread_join ( rmpd->thread ); rmpd->thread = NULL; diff --git a/source/dialogs/run.c b/source/dialogs/run.c index 8b20c290..1d482f04 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -91,7 +91,7 @@ static void exec_cmd ( const char *cmd, int run_in_term ) return; } - char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL ); + char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL ); RofiHelperExecuteContext context = { .name = NULL }; // FIXME: assume startup notification support for terminals if ( helper_execute_command ( NULL, lf_cmd, run_in_term, run_in_term ? &context : NULL ) ) { diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index ccba8eb9..1aa0da0d 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -201,7 +201,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length ) // Reading one line per time. while ( getline ( &buffer, &buffer_length, fd ) > 0 ) { // Evaluate one line. - unsigned int index = 0, ti = 0; + unsigned int index = 0, ti = 0; char *token = buffer; // Tokenize it. diff --git a/source/helper.c b/source/helper.c index 33180096..76835538 100644 --- a/source/helper.c +++ b/source/helper.c @@ -257,7 +257,7 @@ GRegex **tokenize ( const char *input, int case_sensitive ) } char *saveptr = NULL, *token; - GRegex **retv = NULL; + GRegex **retv = NULL; if ( !config.tokenize ) { retv = g_malloc0 ( sizeof ( GRegex* ) * 2 ); retv[0] = (GRegex *) create_regex ( input, case_sensitive ); @@ -896,8 +896,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st // uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial // values suppress warnings. int uleft = 0, ulefts = 0, left, lefts; - const gchar *pit = pattern, *sit; - enum CharClass prev = NON_WORD; + const gchar *pit = pattern, *sit; + enum CharClass prev = NON_WORD; for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) { enum CharClass cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) ); score[si] = rofi_scorer_get_score_for ( prev, cur ); diff --git a/source/rofi.c b/source/rofi.c index 18eb01a5..07639164 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -95,10 +95,10 @@ unsigned int num_modi = 0; /** Current selected mode */ unsigned int curr_switcher = 0; -NkBindings *bindings = NULL; +NkBindings *bindings = NULL; /** Glib main loop. */ -GMainLoop *main_loop = NULL; +GMainLoop *main_loop = NULL; /** Flag indicating we are in dmenu mode. */ static int dmenu_mode = FALSE; diff --git a/source/theme.c b/source/theme.c index f4f41003..3cc64a29 100644 --- a/source/theme.c +++ b/source/theme.c @@ -386,7 +386,8 @@ static ThemeWidget *rofi_theme_find ( ThemeWidget *widget, const char *name, con if ( f != widget ) { widget = f; found = TRUE; - } else if ( exact ) { + } + else if ( exact ) { break; } } @@ -505,7 +506,7 @@ int rofi_theme_get_integer_exact ( const widget *widget, const char *property, i g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property ); return def; } -static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char *property, int def , gboolean exact) +static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char *property, int def, gboolean exact ) { ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, exact ); Property *p = rofi_theme_find_property ( wid, P_PADDING, property, exact ); @@ -521,14 +522,13 @@ static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char return (RofiDistance){ def, ROFI_PU_PX, ROFI_HL_SOLID }; } - RofiDistance rofi_theme_get_distance_exact ( const widget *widget, const char *property, int def ) { - return _rofi_theme_get_distance ( widget, property, def , TRUE ); + return _rofi_theme_get_distance ( widget, property, def, TRUE ); } RofiDistance rofi_theme_get_distance ( const widget *widget, const char *property, int def ) { - return _rofi_theme_get_distance ( widget, property, def , FALSE); + return _rofi_theme_get_distance ( widget, property, def, FALSE ); } int rofi_theme_get_boolean ( const widget *widget, const char *property, int def ) @@ -608,19 +608,19 @@ RofiPadding rofi_theme_get_padding ( const widget *widget, const char *property, GList *rofi_theme_get_list ( const widget *widget, const char * property, const char *defaults ) { ThemeWidget *wid2 = rofi_theme_find_widget ( widget->name, widget->state, TRUE ); - Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE); + Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE ); if ( p ) { - if ( p->type == P_LIST ){ + if ( p->type == P_LIST ) { return g_list_copy_deep ( p->value.list, g_strdup, NULL ); } } - char **r = defaults?g_strsplit (defaults, ",",0):NULL; - if ( r ){ + char **r = defaults ? g_strsplit ( defaults, ",", 0 ) : NULL; + if ( r ) { GList *l = NULL; - for ( int i =0; r[i] != NULL; i++){ - l = g_list_append(l, r[i]); + for ( int i = 0; r[i] != NULL; i++ ) { + l = g_list_append ( l, r[i] ); } - g_free(r); + g_free ( r ); return l; } return NULL; diff --git a/source/view.c b/source/view.c index ef31c738..04c53130 100644 --- a/source/view.c +++ b/source/view.c @@ -652,9 +652,9 @@ void __create_window ( MenuFlags menu_flags ) }; xcb_window_t box_window = xcb_generate_id ( xcb->connection ); - xcb_void_cookie_t cc = xcb_create_window_checked ( xcb->connection, depth->depth, box_window, xcb_stuff_get_root_window ( ), - 0, 0, 200, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, - visual->visual_id, selmask, selval ); + xcb_void_cookie_t cc = xcb_create_window_checked ( xcb->connection, depth->depth, box_window, xcb_stuff_get_root_window ( ), + 0, 0, 200, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, + visual->visual_id, selmask, selval ); xcb_generic_error_t *error; error = xcb_request_check ( xcb->connection, cc ); if ( error ) { @@ -709,7 +709,7 @@ void __create_window ( MenuFlags menu_flags ) } // Setup font. // Dummy widget. - box *win = box_create ( "window.box_window", ROFI_ORIENTATION_HORIZONTAL); + box *win = box_create ( "window.box_window", ROFI_ORIENTATION_HORIZONTAL ); const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font ); if ( font ) { PangoFontDescription *pfd = pango_font_description_from_string ( font ); @@ -1325,7 +1325,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g case SCOPE_MOUSE_SCROLLBAR: case SCOPE_MOUSE_SIDEBAR_MODI: { - gint x = state->mouse.x, y = state->mouse.y; + gint x = state->mouse.x, y = state->mouse.y; widget *target = widget_find_mouse_target ( WIDGET ( state->main_window ), scope, x, y ); if ( target == NULL ) { return FALSE; @@ -1355,7 +1355,7 @@ void rofi_view_handle_text ( RofiViewState *state, char *text ) } } -void rofi_view_handle_mouse_motion( RofiViewState *state, gint x, gint y ) +void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y ) { state->mouse.x = x; state->mouse.y = y; @@ -1372,7 +1372,7 @@ void rofi_view_maybe_update ( RofiViewState *state ) rofi_view_finalize ( state ); // cleanup if ( rofi_view_get_active () == NULL ) { - rofi_quit_main_loop(); + rofi_quit_main_loop (); return; } } @@ -1484,78 +1484,77 @@ static void rofi_view_listview_mouse_activated_cb ( listview *lv, gboolean custo state->skip_absorb = TRUE; } - static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, const char *parent, const char *name ) { - char *defaults = NULL; - widget *wid = NULL; - char *str= g_strjoin ( "." , parent, name, NULL ); - char *strbox= g_strjoin ( "." , str, "box",NULL ); + char *defaults = NULL; + widget *wid = NULL; + char *str = g_strjoin ( ".", parent, name, NULL ); + char *strbox = g_strjoin ( ".", str, "box", NULL ); /** * MAINBOX */ - if ( strcmp ( name, "mainbox") == 0 ){ - wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL ); - box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE ); + if ( strcmp ( name, "mainbox" ) == 0 ) { + wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_VERTICAL ); + box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE ); defaults = "inputbar,message,listview,sidebar"; } /** * INPUTBAR */ - else if ( strcmp ( name, "inputbar" ) == 0 ){ - wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL ); + else if ( strcmp ( name, "inputbar" ) == 0 ) { + wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL ); defaults = "prompt,entry,case-indicator"; - box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE ); + box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE ); } /** * PROMPT */ - else if ( strcmp ( name, "prompt" ) == 0 ){ + else if ( strcmp ( name, "prompt" ) == 0 ) { // Prompt box. state->prompt = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "" ); rofi_view_update_prompt ( state ); - box_add ( (box *)parent_widget, WIDGET ( state->prompt ), FALSE ); + box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE ); defaults = NULL; } /** * CASE INDICATOR */ - else if ( strcmp ( name, "case-indicator") == 0 ){ + else if ( strcmp ( name, "case-indicator" ) == 0 ) { state->case_indicator = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*" ); // Add small separator between case indicator and text box. - box_add ( (box *)parent_widget, WIDGET ( state->case_indicator ), FALSE ); + box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE ); textbox_text ( state->case_indicator, get_matching_state () ); } /** * ENTRY BOX */ - else if ( strcmp ( name, "entry" ) == 0 ){ + else if ( strcmp ( name, "entry" ) == 0 ) { // Entry box TextboxFlags tfl = TB_EDITABLE; tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0; - state->text = textbox_create ( WIDGET_TYPE_EDITBOX, str, tfl | TB_AUTOHEIGHT, NORMAL, NULL); - box_add ( (box*)parent_widget, WIDGET ( state->text ), TRUE ); + state->text = textbox_create ( WIDGET_TYPE_EDITBOX, str, tfl | TB_AUTOHEIGHT, NORMAL, NULL ); + box_add ( (box *) parent_widget, WIDGET ( state->text ), TRUE ); } /** * MESSAGE */ - else if ( strcmp ( name, "message") == 0 ){ - char *strmsg= g_strjoin ( "." , str, "textbox",NULL ); + else if ( strcmp ( name, "message" ) == 0 ) { + char *strmsg = g_strjoin ( ".", str, "textbox", NULL ); state->mesg_box = container_create ( strbox ); state->mesg_tb = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, strmsg, TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL ); container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) ); rofi_view_reload_message_bar ( state ); - box_add ( (box*)parent_widget, WIDGET ( state->mesg_box ), FALSE ); - g_free(strmsg); + box_add ( (box *) parent_widget, WIDGET ( state->mesg_box ), FALSE ); + g_free ( strmsg ); } /** * LISTVIEW */ else if ( strcmp ( name, "listview" ) == 0 ) { - state->list_view = listview_create ( str, update_callback, state, config.element_height, 0); - box_add ( (box*)parent_widget, WIDGET ( state->list_view ), TRUE ); + state->list_view = listview_create ( str, update_callback, state, config.element_height, 0 ); + box_add ( (box *) parent_widget, WIDGET ( state->list_view ), TRUE ); // Set configuration listview_set_multi_select ( state->list_view, ( state->menu_flags & MENU_INDICATOR ) == MENU_INDICATOR ); listview_set_scroll_type ( state->list_view, config.scroll_method ); @@ -1568,39 +1567,41 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, /** * SIDEBAR */ - else if ( strcmp( name, "sidebar" ) == 0 ) { - if ( config.sidebar_mode ){ + else if ( strcmp ( name, "sidebar" ) == 0 ) { + if ( config.sidebar_mode ) { state->sidebar_bar = box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL ); - box_add ( (box*)parent_widget, WIDGET ( state->sidebar_bar ), FALSE ); + box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE ); state->num_modi = rofi_get_num_enabled_modi (); state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) ); - char *strbutton= g_strjoin ( "." , str, "button",NULL ); + char *strbutton = g_strjoin ( ".", str, "button", NULL ); for ( unsigned int j = 0; j < state->num_modi; j++ ) { const Mode * mode = rofi_get_mode ( j ); state->modi[j] = textbox_create ( WIDGET_TYPE_SIDEBAR_MODI, strbutton, TB_CENTER | TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL, - mode_get_display_name ( mode ) ); + mode_get_display_name ( mode ) ); box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE ); widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state ); } - g_free(strbutton); + g_free ( strbutton ); } - } else if ( g_ascii_strncasecmp ( name, "textbox", 7) == 0 ){ - textbox *t = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_WRAP, NORMAL, ""); - box_add ( (box *)parent_widget, WIDGET(t), TRUE); - } else { - wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL ); - box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE ); + } + else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) { + textbox *t = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_WRAP, NORMAL, "" ); + box_add ( (box *) parent_widget, WIDGET ( t ), TRUE ); + } + else { + wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_VERTICAL ); + box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE ); //g_error("The widget %s does not exists. Invalid layout.", name); } if ( wid ) { - GList *list = rofi_theme_get_list ( wid, "children",defaults); - for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter )){ - rofi_view_add_widget ( state, wid, str, (const char *)iter->data ); + GList *list = rofi_theme_get_list ( wid, "children", defaults ); + for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) { + rofi_view_add_widget ( state, wid, str, (const char *) iter->data ); } g_list_free_full ( list, g_free ); } - g_free(strbox); - g_free(str); + g_free ( strbox ); + g_free ( str ); } RofiViewState *rofi_view_create ( Mode *sw, @@ -1630,16 +1631,15 @@ RofiViewState *rofi_view_create ( Mode *sw, // Get active monitor size. TICK_N ( "Get active monitor" ); - state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL ); // Get children. - GList *list = rofi_theme_get_list ( WIDGET(state->main_window), "children", "mainbox"); - for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter )){ - rofi_view_add_widget ( state, WIDGET(state->main_window), "window", (const char *)iter->data ); + GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" ); + for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) { + rofi_view_add_widget ( state, WIDGET ( state->main_window ), "window", (const char *) iter->data ); } g_list_free_full ( list, g_free ); - if ( state->text && input) { + if ( state->text && input ) { textbox_text ( state->text, input ); } @@ -1647,7 +1647,6 @@ RofiViewState *rofi_view_create ( Mode *sw, state->overlay->widget.parent = WIDGET ( state->main_window ); widget_disable ( WIDGET ( state->overlay ) ); - // 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 ) ); @@ -1683,7 +1682,7 @@ int rofi_view_error_dialog ( const char *msg, int markup ) state->finalize = process_result; state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL ); - box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL ); + box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL ); box_add ( state->main_window, WIDGET ( box ), TRUE ); state->text = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "window.mainbox.message.textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ), NORMAL, ( msg != NULL ) ? msg : "" ); diff --git a/source/widgets/box.c b/source/widgets/box.c index 7986cdd3..bd1e1cc8 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -39,23 +39,22 @@ struct _box { - widget widget; + widget widget; RofiOrientation type; - int max_size; + int max_size; // RofiPadding between elements - RofiDistance spacing; + RofiDistance spacing; - GList *children; + GList *children; }; static void box_update ( widget *wid ); - static int box_get_desired_width ( widget *wid ) { box *b = (box *) wid; int spacing = distance_get_pixel ( b->spacing, b->type ); - int width = 0; + int width = 0; if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) { int active_widgets = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { @@ -91,7 +90,7 @@ static int box_get_desired_height ( widget *wid ) box *b = (box *) wid; int spacing = distance_get_pixel ( b->spacing, b->type ); int height = 0; - if ( b->type == ROFI_ORIENTATION_VERTICAL) { + if ( b->type == ROFI_ORIENTATION_VERTICAL ) { int active_widgets = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; @@ -197,8 +196,8 @@ static void hori_calculate_size ( box *b ) widget * child = (widget *) iter->data; if ( child->enabled && child->expand == FALSE ) { widget_resize ( child, - widget_get_desired_width ( child ), //child->w, - rem_height ); + widget_get_desired_width ( child ), //child->w, + rem_height ); } } b->max_size = 0; @@ -340,7 +339,7 @@ box * box_create ( const char *name, RofiOrientation type ) b->widget.get_desired_width = box_get_desired_width; b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE ); - b->type = rofi_theme_get_orientation ( WIDGET (b), "orientation",b->type ); + b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type ); b->spacing = rofi_theme_get_distance ( WIDGET ( b ), "spacing", DEFAULT_SPACING ); return b; diff --git a/source/widgets/listview.c b/source/widgets/listview.c index ec46b53c..b0425ac8 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -37,21 +37,23 @@ #define DEFAULT_SPACING 2 -typedef enum { +typedef enum +{ LISTVIEW = 0, BARVIEW = 1, } ViewType; -typedef enum { - LEFT_TO_RIGHT = 0, - RIGHT_TO_LEFT = 1 +typedef enum +{ + LEFT_TO_RIGHT = 0, + RIGHT_TO_LEFT = 1 } MoveDirection; struct _listview { - widget widget; + widget widget; - ViewType type; + ViewType type; // RChanged // Text needs to be repainted. @@ -100,9 +102,10 @@ struct _listview char *listview_name; /** Barview */ - struct { - MoveDirection direction; - unsigned int cur_visible; + struct + { + MoveDirection direction; + unsigned int cur_visible; } barview; }; @@ -127,14 +130,14 @@ static unsigned int scroll_per_page_barview ( listview *lv ) // selected row is always visible. // If selected is visible do not scroll. if ( lv->selected < lv->last_offset ) { - offset = lv->selected; + offset = lv->selected; lv->rchanged = TRUE; - } else if ( lv->selected >= (lv->last_offset + lv->barview.cur_visible ) ) { - offset = lv->selected; + } + else if ( lv->selected >= ( lv->last_offset + lv->barview.cur_visible ) ) { + offset = lv->selected; lv->rchanged = TRUE; } return offset; - } static unsigned int scroll_per_page ( listview * lv ) { @@ -194,14 +197,14 @@ static void update_element ( listview *lv, unsigned int tb, unsigned int index, static void barview_draw ( widget *wid, cairo_t *draw ) { unsigned int offset = 0; - listview *lv = (listview *) wid; - offset = scroll_per_page_barview ( lv ); + listview *lv = (listview *) wid; + offset = scroll_per_page_barview ( lv ); lv->last_offset = offset; int spacing_hori = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_HORIZONTAL ); - int left_offset = widget_padding_get_left ( wid ); - int right_offset = lv->widget.w - widget_padding_get_right( wid ); - int top_offset = widget_padding_get_top ( wid ); + int left_offset = widget_padding_get_left ( wid ); + int right_offset = lv->widget.w - widget_padding_get_right ( wid ); + int top_offset = widget_padding_get_top ( wid ); if ( lv->cur_elements > 0 ) { // Set new x/y possition. unsigned int max = MIN ( lv->cur_elements, lv->req_elements - offset ); @@ -209,13 +212,13 @@ static void barview_draw ( widget *wid, cairo_t *draw ) int first = TRUE; int width = lv->widget.w; lv->barview.cur_visible = 0; - width -= widget_padding_get_padding_width ( wid ); + width -= widget_padding_get_padding_width ( wid ); if ( lv->barview.direction == LEFT_TO_RIGHT ) { - for ( unsigned int i = 0; i < max&& width > 0; i++ ) { + for ( unsigned int i = 0; i < max && width > 0; i++ ) { update_element ( lv, i, i + offset, TRUE ); - int twidth = textbox_get_desired_width ( WIDGET(lv->boxes[i])); + int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] ) ); if ( twidth >= width ) { - if ( ! first ) { + if ( !first ) { break; } twidth = width; @@ -223,17 +226,18 @@ static void barview_draw ( widget *wid, cairo_t *draw ) textbox_moveresize ( lv->boxes[i], left_offset, top_offset, twidth, lv->element_height ); widget_draw ( WIDGET ( lv->boxes[i] ), draw ); - width -= twidth + spacing_hori; + width -= twidth + spacing_hori; left_offset += twidth + spacing_hori; - first = FALSE; - lv->barview.cur_visible++ ; + first = FALSE; + lv->barview.cur_visible++; } - } else { - for ( unsigned int i = 0; i < lv->cur_elements && width > 0 && i <= offset; i++ ) { - update_element ( lv, i, offset-i, TRUE ); - int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] )); + } + else { + for ( unsigned int i = 0; i < lv->cur_elements && width > 0 && i <= offset; i++ ) { + update_element ( lv, i, offset - i, TRUE ); + int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] ) ); if ( twidth >= width ) { - if ( ! first ) { + if ( !first ) { break; } twidth = width; @@ -242,21 +246,19 @@ static void barview_draw ( widget *wid, cairo_t *draw ) textbox_moveresize ( lv->boxes[i], right_offset, top_offset, twidth, lv->element_height ); widget_draw ( WIDGET ( lv->boxes[i] ), draw ); - width -= twidth + spacing_hori; + width -= twidth + spacing_hori; right_offset -= spacing_hori; - first = FALSE; - lv->barview.cur_visible++ ; + |