Compare commits
No commits in common. "3f132616feec007060f4d992bdefcdcd45f71319" and "a6e66d7cb703cf183e52e9bc7c4c86e375dbbb25" have entirely different histories.
3f132616fe
...
a6e66d7cb7
@ -3,11 +3,11 @@ packages:
|
||||
- build-essential
|
||||
- libwayland-dev
|
||||
- libgtk-3-dev
|
||||
- pkgconf
|
||||
- pkg-config
|
||||
- meson
|
||||
|
||||
tasks:
|
||||
- build: |
|
||||
cd wofi
|
||||
meson setup build
|
||||
meson build
|
||||
ninja -C build
|
||||
|
1
.hgtags
1
.hgtags
@ -9,4 +9,3 @@ e208549963dcd4ae89a18290aa598814c0b8eeb7 v1.2.3
|
||||
84e91980936bf85a854cee6881398cff9d27fce4 v1.2.4
|
||||
1c32143a8460e01559e141c291500a6f4ddcf18c v1.3
|
||||
eab2b31e805564012e4f71920a8f87ba5f9f798c v1.4
|
||||
1e89e8a94806ef2dd27dbf79b4fcc9902f89c422 v1.4.1
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2024 Scoopta
|
||||
* Copyright (C) 2019-2020 Scoopta
|
||||
* This file is part of Wofi
|
||||
* Wofi is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -28,6 +28,6 @@ void config_load(struct map* map, const char* config);
|
||||
|
||||
char* config_get(struct map* config, const char* key, char* def_opt);
|
||||
|
||||
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...);
|
||||
uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...);
|
||||
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@ Gets a config entry, if the entry is not set then it returns \fBdef_opt\fR.
|
||||
\- The default value to be returned if the key does not exist.
|
||||
|
||||
.TP
|
||||
.B int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...)
|
||||
.B uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...)
|
||||
Gets an enum value from the config. If the value is not set then it returns \fBdef_opt\fR.
|
||||
|
||||
.B struct map* config
|
||||
@ -54,7 +54,7 @@ Gets an enum value from the config. If the value is not set then it returns \fBd
|
||||
.B char* def_opt
|
||||
\- The default value to be returned if the key does not exist.
|
||||
|
||||
.B int num_choices
|
||||
.B uint8_t num_choices
|
||||
\- The number of enum options available.
|
||||
|
||||
.B varargs
|
||||
|
@ -195,9 +195,6 @@ Specifies whether or not actions should be executed on a single click or a doubl
|
||||
.TP
|
||||
.B pre_display_exec=\fIBOOL\fR
|
||||
This modifies the behavior of pre_display_cmd and causes the command in question to be directly executed via fork/exec rather than through the shell.
|
||||
.TP
|
||||
.B use_search_box=\fIBOOL\fR
|
||||
Specifies whether or not wofi should use a GtkSearchEntry or a regular GtkEntry. The search entry has a little search icon and a clear text button that the regular entry lacks. Default is true
|
||||
|
||||
.SH CSS SELECTORS
|
||||
Any GTK widget can be selected by using the name of its CSS node, these however might change with updates and are not guaranteed to stay constant. Wofi also provides certain widgets with names and classes which can be referenced from CSS to give access to the most important widgets easily. \fBwofi\fR(7) contains the current widget layout used by wofi so if you want to get into CSS directly using GTK widget names look there for info.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2024 Scoopta
|
||||
* Copyright (C) 2019-2020 Scoopta
|
||||
* This file is part of Wofi
|
||||
* Wofi is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -81,12 +81,12 @@ char* config_get(struct map* config, const char* key, char* def_opt) {
|
||||
return opt;
|
||||
}
|
||||
|
||||
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...) {
|
||||
uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...) {
|
||||
char* opt = config_get(config, key, def_opt);
|
||||
va_list ap;
|
||||
va_start(ap, num_choices);
|
||||
int result = 0;
|
||||
for(int i = 0; i < num_choices; i++) {
|
||||
uint8_t result = 0;
|
||||
for(uint8_t i = 0; i < num_choices; i++) {
|
||||
char* cmp_str = va_arg(ap, char*);
|
||||
if(strcmp(opt, cmp_str) == 0) {
|
||||
result = i;
|
||||
|
42
src/wofi.c
42
src/wofi.c
@ -109,7 +109,6 @@ static char* copy_exec = NULL;
|
||||
static char* pre_display_cmd = NULL;
|
||||
static bool pre_display_exec = false;
|
||||
static bool single_click = false;
|
||||
static bool hide_search = false;
|
||||
static GdkModifierType shift_mask = GDK_SHIFT_MASK;
|
||||
static GdkModifierType ctrl_mask = GDK_CONTROL_MASK;
|
||||
static GdkModifierType alt_mask = GDK_MOD1_MASK;
|
||||
@ -927,16 +926,7 @@ struct wl_list* wofi_read_cache(struct mode* mode) {
|
||||
smallest_node = node;
|
||||
}
|
||||
}
|
||||
|
||||
char* space = strchr(smallest_node->line, ' ');
|
||||
|
||||
if(space == NULL) {
|
||||
free(smallest_node->line);
|
||||
wl_list_remove(&smallest_node->link);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* tmp = strdup(space + 1);
|
||||
char* tmp = strdup(strchr(smallest_node->line, ' ') + 1);
|
||||
free(smallest_node->line);
|
||||
smallest_node->line = tmp;
|
||||
wl_list_remove(&smallest_node->link);
|
||||
@ -1131,8 +1121,8 @@ static gint do_sort(GtkFlowBoxChild* child1, GtkFlowBoxChild* child2, gpointer d
|
||||
return sort_for_matching_mode(text1, text2, fallback, matching, filter, insensitive);
|
||||
}
|
||||
|
||||
static void select_idx(gint idx) {
|
||||
GtkFlowBoxChild* child = gtk_flow_box_get_child_at_index(GTK_FLOW_BOX(inner_box), idx);
|
||||
static void select_first(void) {
|
||||
GtkFlowBoxChild* child = gtk_flow_box_get_child_at_index(GTK_FLOW_BOX(inner_box), 0);
|
||||
gtk_widget_grab_focus(GTK_WIDGET(child));
|
||||
gtk_flow_box_select_child(GTK_FLOW_BOX(inner_box), GTK_FLOW_BOX_CHILD(child));
|
||||
}
|
||||
@ -1185,7 +1175,7 @@ static void move_down(void) {
|
||||
user_moved = true;
|
||||
if(outer_orientation == GTK_ORIENTATION_VERTICAL) {
|
||||
if(gtk_widget_has_focus(entry) || gtk_widget_has_focus(scroll)) {
|
||||
select_idx(1);
|
||||
select_first();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1201,7 +1191,7 @@ static void move_right(void) {
|
||||
user_moved = true;
|
||||
if(outer_orientation == GTK_ORIENTATION_HORIZONTAL) {
|
||||
if(gtk_widget_has_focus(entry) || gtk_widget_has_focus(scroll)) {
|
||||
select_idx(1);
|
||||
select_first();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1211,14 +1201,14 @@ static void move_right(void) {
|
||||
static void move_forward(void) {
|
||||
user_moved = true;
|
||||
if(gtk_widget_has_focus(entry) || gtk_widget_has_focus(scroll)) {
|
||||
select_idx(1);
|
||||
select_first();
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_child_focus(window, GTK_DIR_TAB_FORWARD);
|
||||
|
||||
if(gtk_widget_has_focus(entry)) {
|
||||
select_idx(0);
|
||||
select_first();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1757,12 +1747,6 @@ static gboolean do_percent_size_first(gpointer data){
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static gboolean hide_search_first(gpointer data) {
|
||||
(void) data;
|
||||
gtk_widget_set_visible(entry, !hide_search);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void wofi_init(struct map* _config) {
|
||||
config = _config;
|
||||
char* width_str = config_get(config, "width", "50%");
|
||||
@ -1812,7 +1796,7 @@ void wofi_init(struct map* _config) {
|
||||
sort_order = config_get_mnemonic(config, "sort_order", "default", 2, "default", "alphabetical");
|
||||
line_wrap = config_get_mnemonic(config, "line_wrap", "off", 4, "off", "word", "char", "word_char") - 1;
|
||||
bool global_coords = strcmp(config_get(config, "global_coords", "false"), "true") == 0;
|
||||
hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0;
|
||||
bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0;
|
||||
char* search = map_get(config, "search");
|
||||
dynamic_lines = strcmp(config_get(config, "dynamic_lines", "false"), "true") == 0;
|
||||
char* monitor = map_get(config, "monitor");
|
||||
@ -2013,19 +1997,13 @@ void wofi_init(struct map* _config) {
|
||||
outer_box = gtk_box_new(outer_orientation, 0);
|
||||
gtk_widget_set_name(outer_box, "outer-box");
|
||||
gtk_container_add(GTK_CONTAINER(window), outer_box);
|
||||
|
||||
bool use_search_box = strcmp(config_get(config, "use_search_box", "true"), "true") == 0;
|
||||
if(use_search_box) {
|
||||
entry = gtk_search_entry_new();
|
||||
} else {
|
||||
entry = gtk_entry_new();
|
||||
}
|
||||
|
||||
g_signal_connect(entry, "size-allocate", G_CALLBACK(widget_allocate), NULL);
|
||||
|
||||
gtk_widget_set_name(entry, "input");
|
||||
gtk_entry_set_placeholder_text(GTK_ENTRY(entry), prompt);
|
||||
gtk_container_add(GTK_CONTAINER(outer_box), entry);
|
||||
gtk_widget_set_child_visible(entry, !hide_search);
|
||||
|
||||
if(search != NULL) {
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), search);
|
||||
@ -2085,8 +2063,6 @@ void wofi_init(struct map* _config) {
|
||||
gdk_threads_add_timeout(25, do_percent_size_first, geo_str);
|
||||
}
|
||||
|
||||
gdk_threads_add_timeout(5, hide_search_first, NULL);
|
||||
|
||||
wl_list_init(&mode_list);
|
||||
|
||||
pthread_create(&mode_thread, NULL, start_mode_thread, mode);
|
||||
|
Loading…
Reference in New Issue
Block a user