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:
parent
7d3a365ccf
commit
bb5868199f
18 changed files with 161 additions and 141 deletions
|
@ -397,7 +397,8 @@ char *helper_string_replace_if_exists(char *string, ...);
|
||||||
*
|
*
|
||||||
* @returns path to theme or copy of filename if not found.
|
* @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.
|
* @param name The name of the element to find.
|
||||||
|
|
|
@ -356,7 +356,6 @@ void rofi_view_ellipsize_listview(RofiViewState *state,
|
||||||
*/
|
*/
|
||||||
gboolean rofi_set_im_window_pos(int new_x, int new_y);
|
gboolean rofi_set_im_window_pos(int new_x, int new_y);
|
||||||
|
|
||||||
|
|
||||||
WidgetTriggerActionResult textbox_button_trigger_action(
|
WidgetTriggerActionResult textbox_button_trigger_action(
|
||||||
widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x,
|
widget *wid, MouseBindingMouseDefaultAction action, G_GNUC_UNUSED gint x,
|
||||||
G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data);
|
G_GNUC_UNUSED gint y, G_GNUC_UNUSED void *user_data);
|
||||||
|
|
|
@ -180,7 +180,8 @@ static char *utf8_helper_simplify_string(const char *os) {
|
||||||
0,
|
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);
|
char *s = g_utf8_normalize(os, -1, G_NORMALIZE_ALL);
|
||||||
ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char);
|
ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char);
|
||||||
char *str = g_malloc0(str_size);
|
char *str = g_malloc0(str_size);
|
||||||
|
|
|
@ -346,7 +346,8 @@ static void get_file_browser(Mode *sw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void file_browser_mode_init_config(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;
|
char *msg = NULL;
|
||||||
gboolean found_error = FALSE;
|
gboolean found_error = FALSE;
|
||||||
|
|
||||||
|
@ -390,7 +391,6 @@ static void file_browser_mode_init_config(Mode *sw) {
|
||||||
pd->command = g_strdup(DEFAULT_OPEN);
|
pd->command = g_strdup(DEFAULT_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (found_error) {
|
if (found_error) {
|
||||||
rofi_view_error_dialog(msg, FALSE);
|
rofi_view_error_dialog(msg, FALSE);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "modes/help-keys.h"
|
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include "modes/help-keys.h"
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "widgets/textbox.h"
|
#include "widgets/textbox.h"
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "modes/ssh.h"
|
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
#include "modes/ssh.h"
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
|
|
@ -804,8 +804,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
|
||||||
return G_SOURCE_REMOVE;
|
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_capture_screenshot();
|
||||||
rofi_quit_main_loop();
|
rofi_quit_main_loop();
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
|
|
|
@ -103,7 +103,6 @@ GThreadPool *tpool = NULL;
|
||||||
/** Global pointer to the currently active RofiViewState */
|
/** Global pointer to the currently active RofiViewState */
|
||||||
RofiViewState *current_active_menu = NULL;
|
RofiViewState *current_active_menu = NULL;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *string;
|
char *string;
|
||||||
int index;
|
int index;
|
||||||
|
@ -159,8 +158,7 @@ struct {
|
||||||
EntryHistoryIndex *entry_history;
|
EntryHistoryIndex *entry_history;
|
||||||
gssize entry_history_length;
|
gssize entry_history_length;
|
||||||
gssize entry_history_index;
|
gssize entry_history_index;
|
||||||
} CacheState = {
|
} CacheState = {.main_window = XCB_WINDOW_NONE,
|
||||||
.main_window = XCB_WINDOW_NONE,
|
|
||||||
.fake_bg = NULL,
|
.fake_bg = NULL,
|
||||||
.edit_surf = NULL,
|
.edit_surf = NULL,
|
||||||
.edit_draw = NULL,
|
.edit_draw = NULL,
|
||||||
|
@ -179,8 +177,7 @@ struct {
|
||||||
.entry_history_enable = TRUE,
|
.entry_history_enable = TRUE,
|
||||||
.entry_history = NULL,
|
.entry_history = NULL,
|
||||||
.entry_history_length = 0,
|
.entry_history_length = 0,
|
||||||
.entry_history_index = 0
|
.entry_history_index = 0};
|
||||||
};
|
|
||||||
|
|
||||||
void rofi_view_get_current_monitor(int *width, int *height) {
|
void rofi_view_get_current_monitor(int *width, int *height) {
|
||||||
if (width) {
|
if (width) {
|
||||||
|
@ -900,8 +897,7 @@ static void open_xim_callback(xcb_xim_t *im, G_GNUC_UNUSED void *user_data) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void input_history_initialize ( void )
|
static void input_history_initialize(void) {
|
||||||
{
|
|
||||||
if (CacheState.entry_history_enable == FALSE) {
|
if (CacheState.entry_history_enable == FALSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -917,14 +913,17 @@ static void input_history_initialize ( void )
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
while ((nread = getline(&line, &len, fp)) != -1) {
|
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));
|
sizeof(EntryHistoryIndex) * (CacheState.entry_history_length + 1));
|
||||||
if (line[nread - 1] == '\n') {
|
if (line[nread - 1] == '\n') {
|
||||||
line[nread - 1] = '\0';
|
line[nread - 1] = '\0';
|
||||||
nread--;
|
nread--;
|
||||||
}
|
}
|
||||||
CacheState.entry_history[CacheState.entry_history_length].string = g_strdup(line);
|
CacheState.entry_history[CacheState.entry_history_length].string =
|
||||||
CacheState.entry_history[CacheState.entry_history_length].index = strlen(line);
|
g_strdup(line);
|
||||||
|
CacheState.entry_history[CacheState.entry_history_length].index =
|
||||||
|
strlen(line);
|
||||||
CacheState.entry_history_length++;
|
CacheState.entry_history_length++;
|
||||||
CacheState.entry_history_index++;
|
CacheState.entry_history_index++;
|
||||||
}
|
}
|
||||||
|
@ -933,15 +932,15 @@ static void input_history_initialize ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free(path);
|
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));
|
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[CacheState.entry_history_length].index = 0;
|
||||||
CacheState.entry_history_length++;
|
CacheState.entry_history_length++;
|
||||||
|
|
||||||
}
|
}
|
||||||
static void input_history_save ( void )
|
static void input_history_save(void) {
|
||||||
{
|
|
||||||
if (CacheState.entry_history_enable == FALSE) {
|
if (CacheState.entry_history_enable == FALSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -950,7 +949,8 @@ static void input_history_save ( void )
|
||||||
int max_history = 20;
|
int max_history = 20;
|
||||||
ThemeWidget *wid = rofi_config_find_widget("entry", NULL, TRUE);
|
ThemeWidget *wid = rofi_config_find_widget("entry", NULL, TRUE);
|
||||||
if (wid) {
|
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) {
|
if (p != NULL && p->type == P_INTEGER) {
|
||||||
max_history = p->value.i;
|
max_history = p->value.i;
|
||||||
}
|
}
|
||||||
|
@ -1580,11 +1580,14 @@ static void rofi_view_input_changed() {
|
||||||
|
|
||||||
RofiViewState *state = current_active_menu;
|
RofiViewState *state = current_active_menu;
|
||||||
if (CacheState.entry_history_enable && state) {
|
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);
|
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].string =
|
||||||
CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text);
|
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: {
|
case ENTRY_HISTORY_DOWN: {
|
||||||
if (CacheState.entry_history_enable && state->text) {
|
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) {
|
if (CacheState.entry_history_index > 0) {
|
||||||
CacheState.entry_history_index--;
|
CacheState.entry_history_index--;
|
||||||
}
|
}
|
||||||
if (state->text) {
|
if (state->text) {
|
||||||
textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string);
|
textbox_text(
|
||||||
textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index );
|
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;
|
state->refilter = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1857,24 +1865,36 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
|
||||||
}
|
}
|
||||||
case ENTRY_HISTORY_UP: {
|
case ENTRY_HISTORY_UP: {
|
||||||
if (CacheState.entry_history_enable && state->text) {
|
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);
|
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].string =
|
||||||
CacheState.entry_history[CacheState.entry_history_index].index = textbox_get_cursor(state->text);
|
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.
|
// 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++;
|
CacheState.entry_history_index++;
|
||||||
if (CacheState.entry_history_index >= CacheState.entry_history_length) {
|
if (CacheState.entry_history_index >= CacheState.entry_history_length) {
|
||||||
CacheState.entry_history = g_realloc(CacheState.entry_history,
|
CacheState.entry_history =
|
||||||
sizeof(EntryHistoryIndex)*(CacheState.entry_history_length+1));
|
g_realloc(CacheState.entry_history,
|
||||||
CacheState.entry_history[CacheState.entry_history_length].string = g_strdup("");
|
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[CacheState.entry_history_length].index = 0;
|
||||||
CacheState.entry_history_length++;
|
CacheState.entry_history_length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
textbox_text(state->text, CacheState.entry_history[CacheState.entry_history_index].string);
|
textbox_text(
|
||||||
textbox_cursor(state->text,CacheState.entry_history[CacheState.entry_history_index].index );
|
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;
|
state->refilter = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#define G_LOG_DOMAIN "Widgets.Container"
|
#define G_LOG_DOMAIN "Widgets.Container"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "widgets/container.h"
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
#include "widgets/container.h"
|
||||||
#include "widgets/widget-internal.h"
|
#include "widgets/widget-internal.h"
|
||||||
#include "widgets/widget.h"
|
#include "widgets/widget.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#define G_LOG_DOMAIN "Widgets.Icon"
|
#define G_LOG_DOMAIN "Widgets.Icon"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "widgets/icon.h"
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
#include "widgets/icon.h"
|
||||||
#include "widgets/widget-internal.h"
|
#include "widgets/widget-internal.h"
|
||||||
#include "widgets/widget.h"
|
#include "widgets/widget.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -190,21 +190,22 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
|
||||||
box_add((box *)wid, WIDGET(textbox_custom), TRUE);
|
box_add((box *)wid, WIDGET(textbox_custom), TRUE);
|
||||||
} else if (strncasecmp(label, "button", 6) == 0) {
|
} else if (strncasecmp(label, "button", 6) == 0) {
|
||||||
textbox *button_custom =
|
textbox *button_custom =
|
||||||
textbox_create(wid, WIDGET_TYPE_EDITBOX, label,
|
textbox_create(wid, WIDGET_TYPE_EDITBOX, label, TB_AUTOHEIGHT | TB_WRAP,
|
||||||
TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0);
|
NORMAL, "", 0, 0);
|
||||||
box_add((box *)wid, WIDGET(button_custom), TRUE);
|
box_add((box *)wid, WIDGET(button_custom), TRUE);
|
||||||
widget_set_trigger_action_handler(WIDGET(button_custom), textbox_button_trigger_action,
|
widget_set_trigger_action_handler(WIDGET(button_custom),
|
||||||
lv->udata);
|
textbox_button_trigger_action, lv->udata);
|
||||||
} else if (strncasecmp(label, "icon", 4) == 0) {
|
} else if (strncasecmp(label, "icon", 4) == 0) {
|
||||||
icon *icon_custom = icon_create(wid, label);
|
icon *icon_custom = icon_create(wid, label);
|
||||||
/* small hack to make it clickable */
|
/* 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) {
|
if (type) {
|
||||||
WIDGET(icon_custom)->type = WIDGET_TYPE_EDITBOX;
|
WIDGET(icon_custom)->type = WIDGET_TYPE_EDITBOX;
|
||||||
}
|
}
|
||||||
box_add((box *)wid, WIDGET(icon_custom), TRUE);
|
box_add((box *)wid, WIDGET(icon_custom), TRUE);
|
||||||
widget_set_trigger_action_handler(WIDGET(icon_custom), textbox_button_trigger_action,
|
widget_set_trigger_action_handler(WIDGET(icon_custom),
|
||||||
lv->udata);
|
textbox_button_trigger_action, lv->udata);
|
||||||
} else {
|
} else {
|
||||||
widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL);
|
widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL);
|
||||||
box_add((box *)wid, WIDGET(wid2), TRUE);
|
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) {
|
if (lv->widget.h == 0) {
|
||||||
lv->max_rows = lv->menu_lines;
|
lv->max_rows = lv->menu_lines;
|
||||||
} else {
|
} 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;
|
lv->max_elements = lv->max_rows * lv->menu_columns;
|
||||||
|
|
||||||
|
|
|
@ -365,9 +365,7 @@ char *textbox_get_text ( const textbox *tb ) {
|
||||||
}
|
}
|
||||||
return g_strdup(tb->text);
|
return g_strdup(tb->text);
|
||||||
}
|
}
|
||||||
int textbox_get_cursor ( const textbox *tb ) {
|
int textbox_get_cursor(const textbox *tb) { return tb->cursor; }
|
||||||
return tb->cursor;
|
|
||||||
}
|
|
||||||
// set the default text to display
|
// set the default text to display
|
||||||
void textbox_text(textbox *tb, const char *text) {
|
void textbox_text(textbox *tb, const char *text) {
|
||||||
if (tb == NULL) {
|
if (tb == NULL) {
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "widgets/widget.h"
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "widgets/widget-internal.h"
|
#include "widgets/widget-internal.h"
|
||||||
|
#include "widgets/widget.h"
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue