1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Re-indent the code using clang-format

This commit is contained in:
Dave Davenport 2023-03-26 13:19:58 +02:00
parent 7d3a365ccf
commit bb5868199f
18 changed files with 161 additions and 141 deletions

View file

@ -397,7 +397,8 @@ char *helper_string_replace_if_exists(char *string, ...);
*
* @returns path to theme or copy of filename if not found.
*/
char *helper_get_theme_path(const char *file, const char **ext) __attribute__((nonnull));
char *helper_get_theme_path(const char *file, const char **ext)
__attribute__((nonnull));
/**
* @param name The name of the element to find.

View file

@ -356,7 +356,6 @@ void rofi_view_ellipsize_listview(RofiViewState *state,
*/
gboolean rofi_set_im_window_pos(int new_x, int new_y);
WidgetTriggerActionResult textbox_button_trigger_action(
widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x,
G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data);

View file

@ -180,7 +180,8 @@ static char *utf8_helper_simplify_string(const char *os) {
0,
};
// Normalize the string to a fully decomposed form, then filter out mark/accent characters.
// Normalize the string to a fully decomposed form, then filter out
// mark/accent characters.
char *s = g_utf8_normalize(os, -1, G_NORMALIZE_ALL);
ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char);
char *str = g_malloc0(str_size);

View file

@ -346,7 +346,8 @@ static void get_file_browser(Mode *sw) {
}
static void file_browser_mode_init_config(Mode *sw) {
FileBrowserModePrivateData * pd = (FileBrowserModePrivateData*)mode_get_private_data(sw);
FileBrowserModePrivateData *pd =
(FileBrowserModePrivateData *)mode_get_private_data(sw);
char *msg = NULL;
gboolean found_error = FALSE;
@ -390,7 +391,6 @@ static void file_browser_mode_init_config(Mode *sw) {
pd->command = g_strdup(DEFAULT_OPEN);
}
if (found_error) {
rofi_view_error_dialog(msg, FALSE);

View file

@ -38,8 +38,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "modes/help-keys.h"
#include "helper.h"
#include "modes/help-keys.h"
#include "rofi.h"
#include "settings.h"
#include "widgets/textbox.h"

View file

@ -51,8 +51,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "modes/ssh.h"
#include "history.h"
#include "modes/ssh.h"
#include "rofi.h"
#include "settings.h"

View file

@ -804,8 +804,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
return G_SOURCE_REMOVE;
}
static gboolean take_screenshot_quit ( G_GNUC_UNUSED void *data)
{
static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data) {
rofi_capture_screenshot();
rofi_quit_main_loop();
return G_SOURCE_REMOVE;

View file

@ -103,7 +103,6 @@ GThreadPool *tpool = NULL;
/** Global pointer to the currently active RofiViewState */
RofiViewState *current_active_menu = NULL;
typedef struct {
char *string;
int index;
@ -159,8 +158,7 @@ struct {
EntryHistoryIndex *entry_history;
gssize entry_history_length;
gssize entry_history_index;
} CacheState = {
.main_window = XCB_WINDOW_NONE,
} CacheState = {.main_window = XCB_WINDOW_NONE,
.fake_bg = NULL,
.edit_surf = NULL,
.edit_draw = NULL,
@ -179,8 +177,7 @@ struct {
.entry_history_enable = TRUE,
.entry_history = NULL,
.entry_history_length = 0,
.entry_history_index = 0
};
.entry_history_index = 0};
void rofi_view_get_current_monitor(int *width, int *height) {
if (width) {
@ -900,8 +897,7 @@ static void open_xim_callback(xcb_xim_t *im, G_GNUC_UNUSED void *user_data) {
}
#endif
static void input_history_initialize ( void )
{
static void input_history_initialize(void) {
if (CacheState.entry_history_enable == FALSE) {
return;
}
@ -917,14 +913,17 @@ static void input_history_initialize ( void )
size_t len = 0;
ssize_t nread;
while ((nread = getline(&line, &len, fp)) != -1) {
CacheState.entry_history = g_realloc(CacheState.entry_history,
CacheState.entry_history = g_realloc(
CacheState.entry_history,
sizeof(EntryHistoryIndex) * (CacheState.entry_history_length + 1));
if (line[nread - 1] == '\n') {
line[nread - 1] = '\0';
nread--;
}
CacheState.entry_history[CacheState.entry_history_length].string = g_strdup(line);
CacheState.entry_history[CacheState.entry_history_length].index = strlen(line);
CacheState.entry_history[CacheState.entry_history_length].string =
g_strdup(line);
CacheState.entry_history[CacheState.entry_history_length].index =
strlen(line);
CacheState.entry_history_length++;
CacheState.entry_history_index++;
}
@ -933,15 +932,15 @@ static void input_history_initialize ( void )
}
}
g_free(path);
CacheState.entry_history = g_realloc(CacheState.entry_history,
CacheState.entry_history = g_realloc(
CacheState.entry_history,
sizeof(EntryHistoryIndex) * (CacheState.entry_history_length + 1));
CacheState.entry_history[CacheState.entry_history_length].string = g_strdup("");
CacheState.entry_history[CacheState.entry_history_length].string =
g_strdup("");
CacheState.entry_history[CacheState.entry_history_length].index = 0;
CacheState.entry_history_length++;
}
static void input_history_save ( void )
{
static void input_history_save(void) {
if (CacheState.entry_history_enable == FALSE) {
return;
}
@ -950,7 +949,8 @@ static void input_history_save ( void )
int max_history = 20;
ThemeWidget *wid = rofi_config_find_widget("entry", NULL, TRUE);
if (wid) {
Property *p = rofi_theme_find_property(wid, P_INTEGER, "max-history", TRUE);
Property *p =
rofi_theme_find_property(wid, P_INTEGER, "max-history", TRUE);
if (p != NULL && p->type == P_INTEGER) {
max_history = p->value.i;
}
@ -1580,11 +1580,14 @@ static void rofi_view_input_changed() {
RofiViewState *state = current_active_menu;
if (CacheState.entry_history_enable && state) {
if ( CacheState.entry_history[CacheState.entry_history_index].string != NULL) {
if (CacheState.entry_history[CacheState.entry_history_index].string !=
NULL) {
g_free(CacheState.entry_history[CacheState.entry_history_index].string);
}
CacheState.entry_history[CacheState.entry_history_index].string = textbox_get_text(state->text);
CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text);
CacheState.entry_history[CacheState.entry_history_index].string =
textbox_get_text(state->text);
CacheState.entry_history[CacheState.entry_history_index].index =
textbox_get_cursor(state->text);
}
}
@ -1843,13 +1846,18 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
}
case ENTRY_HISTORY_DOWN: {
if (CacheState.entry_history_enable && state->text) {
CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text);
CacheState.entry_history[CacheState.entry_history_index].index =
textbox_get_cursor(state->text);
if (CacheState.entry_history_index > 0) {
CacheState.entry_history_index--;
}
if (state->text) {
textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string);
textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index );
textbox_text(
state->text,
CacheState.entry_history[CacheState.entry_history_index].string);
textbox_cursor(
state->text,
CacheState.entry_history[CacheState.entry_history_index].index);
state->refilter = TRUE;
}
}
@ -1857,24 +1865,36 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
}
case ENTRY_HISTORY_UP: {
if (CacheState.entry_history_enable && state->text) {
if ( CacheState.entry_history[CacheState.entry_history_index].string != NULL) {
if (CacheState.entry_history[CacheState.entry_history_index].string !=
NULL) {
g_free(CacheState.entry_history[CacheState.entry_history_index].string);
}
CacheState.entry_history[CacheState.entry_history_index].string = textbox_get_text(state->text);
CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text);
CacheState.entry_history[CacheState.entry_history_index].string =
textbox_get_text(state->text);
CacheState.entry_history[CacheState.entry_history_index].index =
textbox_get_cursor(state->text);
// Don't create up if current is empty.
if ( strlen(CacheState.entry_history[CacheState.entry_history_index].string) > 0 ) {
if (strlen(
CacheState.entry_history[CacheState.entry_history_index].string) >
0) {
CacheState.entry_history_index++;
if (CacheState.entry_history_index >= CacheState.entry_history_length) {
CacheState.entry_history = g_realloc(CacheState.entry_history,
sizeof(EntryHistoryIndex)*(CacheState.entry_history_length+1));
CacheState.entry_history[CacheState.entry_history_length].string = g_strdup("");
CacheState.entry_history =
g_realloc(CacheState.entry_history,
sizeof(EntryHistoryIndex) *
(CacheState.entry_history_length + 1));
CacheState.entry_history[CacheState.entry_history_length].string =
g_strdup("");
CacheState.entry_history[CacheState.entry_history_length].index = 0;
CacheState.entry_history_length++;
}
}
textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string);
textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index );
textbox_text(
state->text,
CacheState.entry_history[CacheState.entry_history_index].string);
textbox_cursor(
state->text,
CacheState.entry_history[CacheState.entry_history_index].index);
state->refilter = TRUE;
}
break;

View file

@ -29,8 +29,8 @@
#define G_LOG_DOMAIN "Widgets.Container"
#include "config.h"
#include "widgets/container.h"
#include "theme.h"
#include "widgets/container.h"
#include "widgets/widget-internal.h"
#include "widgets/widget.h"
#include <stdio.h>

View file

@ -29,8 +29,8 @@
#define G_LOG_DOMAIN "Widgets.Icon"
#include "config.h"
#include "widgets/icon.h"
#include "theme.h"
#include "widgets/icon.h"
#include "widgets/widget-internal.h"
#include "widgets/widget.h"
#include <stdio.h>

View file

@ -190,21 +190,22 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
box_add((box *)wid, WIDGET(textbox_custom), TRUE);
} else if (strncasecmp(label, "button", 6) == 0) {
textbox *button_custom =
textbox_create(wid, WIDGET_TYPE_EDITBOX, label,
TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0);
textbox_create(wid, WIDGET_TYPE_EDITBOX, label, TB_AUTOHEIGHT | TB_WRAP,
NORMAL, "", 0, 0);
box_add((box *)wid, WIDGET(button_custom), TRUE);
widget_set_trigger_action_handler(WIDGET(button_custom), textbox_button_trigger_action,
lv->udata);
widget_set_trigger_action_handler(WIDGET(button_custom),
textbox_button_trigger_action, lv->udata);
} else if (strncasecmp(label, "icon", 4) == 0) {
icon *icon_custom = icon_create(wid, label);
/* small hack to make it clickable */
const char *type = rofi_theme_get_string(WIDGET(icon_custom), "action", NULL);
const char *type =
rofi_theme_get_string(WIDGET(icon_custom), "action", NULL);
if (type) {
WIDGET(icon_custom)->type = WIDGET_TYPE_EDITBOX;
}
box_add((box *)wid, WIDGET(icon_custom), TRUE);
widget_set_trigger_action_handler(WIDGET(icon_custom), textbox_button_trigger_action,
lv->udata);
widget_set_trigger_action_handler(WIDGET(icon_custom),
textbox_button_trigger_action, lv->udata);
} else {
widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL);
box_add((box *)wid, WIDGET(wid2), TRUE);
@ -633,7 +634,8 @@ static void listview_resize(widget *wid, short w, short h) {
if (lv->widget.h == 0) {
lv->max_rows = lv->menu_lines;
} else {
lv->max_rows = (spacing_vert + height) / (lv->element_height + spacing_vert);
lv->max_rows =
(spacing_vert + height) / (lv->element_height + spacing_vert);
}
lv->max_elements = lv->max_rows * lv->menu_columns;

View file

@ -365,9 +365,7 @@ char *textbox_get_text ( const textbox *tb ) {
}
return g_strdup(tb->text);
}
int textbox_get_cursor ( const textbox *tb ) {
return tb->cursor;
}
int textbox_get_cursor(const textbox *tb) { return tb->cursor; }
// set the default text to display
void textbox_text(textbox *tb, const char *text) {
if (tb == NULL) {

View file

@ -26,9 +26,9 @@
*/
#include "config.h"
#include "widgets/widget.h"
#include "theme.h"
#include "widgets/widget-internal.h"
#include "widgets/widget.h"
#include <glib.h>
#include <math.h>