Compare commits
10 Commits
a6e66d7cb7
...
3f132616fe
Author | SHA1 | Date | |
---|---|---|---|
|
3f132616fe | ||
|
c7207c4d25 | ||
|
31640832d7 | ||
|
192ec0e13a | ||
|
8f384c3e2a | ||
|
10c2a2a2d0 | ||
|
39ac8366fe | ||
|
fa72a9e6b9 | ||
|
a9868654c2 | ||
|
c725ce2496 |
@ -3,11 +3,11 @@ packages:
|
||||
- build-essential
|
||||
- libwayland-dev
|
||||
- libgtk-3-dev
|
||||
- pkg-config
|
||||
- pkgconf
|
||||
- meson
|
||||
|
||||
tasks:
|
||||
- build: |
|
||||
cd wofi
|
||||
meson build
|
||||
meson setup build
|
||||
ninja -C build
|
||||
|
1
.hgtags
1
.hgtags
@ -9,3 +9,4 @@ 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-2020 Scoopta
|
||||
* Copyright (C) 2019-2024 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);
|
||||
|
||||
uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...);
|
||||
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int 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 uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...)
|
||||
.B int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int 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 uint8_t num_choices
|
||||
.B int num_choices
|
||||
\- The number of enum options available.
|
||||
|
||||
.B varargs
|
||||
|
@ -195,6 +195,9 @@ 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-2020 Scoopta
|
||||
* Copyright (C) 2019-2024 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;
|
||||
}
|
||||
|
||||
uint8_t config_get_mnemonic(struct map* config, const char* key, char* def_opt, uint8_t num_choices, ...) {
|
||||
int config_get_mnemonic(struct map* config, const char* key, char* def_opt, int num_choices, ...) {
|
||||
char* opt = config_get(config, key, def_opt);
|
||||
va_list ap;
|
||||
va_start(ap, num_choices);
|
||||
uint8_t result = 0;
|
||||
for(uint8_t i = 0; i < num_choices; i++) {
|
||||
int result = 0;
|
||||
for(int 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,6 +109,7 @@ 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;
|
||||
@ -926,7 +927,16 @@ struct wl_list* wofi_read_cache(struct mode* mode) {
|
||||
smallest_node = node;
|
||||
}
|
||||
}
|
||||
char* tmp = strdup(strchr(smallest_node->line, ' ') + 1);
|
||||
|
||||
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);
|
||||
free(smallest_node->line);
|
||||
smallest_node->line = tmp;
|
||||
wl_list_remove(&smallest_node->link);
|
||||
@ -1121,8 +1131,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_first(void) {
|
||||
GtkFlowBoxChild* child = gtk_flow_box_get_child_at_index(GTK_FLOW_BOX(inner_box), 0);
|
||||
static void select_idx(gint idx) {
|
||||
GtkFlowBoxChild* child = gtk_flow_box_get_child_at_index(GTK_FLOW_BOX(inner_box), idx);
|
||||
gtk_widget_grab_focus(GTK_WIDGET(child));
|
||||
gtk_flow_box_select_child(GTK_FLOW_BOX(inner_box), GTK_FLOW_BOX_CHILD(child));
|
||||
}
|
||||
@ -1175,7 +1185,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_first();
|
||||
select_idx(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1191,7 +1201,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_first();
|
||||
select_idx(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1201,14 +1211,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_first();
|
||||
select_idx(1);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_child_focus(window, GTK_DIR_TAB_FORWARD);
|
||||
|
||||
if(gtk_widget_has_focus(entry)) {
|
||||
select_first();
|
||||
select_idx(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1747,6 +1757,12 @@ 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%");
|
||||
@ -1796,7 +1812,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;
|
||||
bool hide_search = strcmp(config_get(config, "hide_search", "false"), "true") == 0;
|
||||
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");
|
||||
@ -1997,13 +2013,19 @@ 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);
|
||||
@ -2063,6 +2085,8 @@ 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