small updates

This commit is contained in:
Dave Davenport 2022-11-17 17:41:43 +01:00
parent ff08041483
commit 9dc80f8f73
1 changed files with 25 additions and 21 deletions

View File

@ -24,12 +24,12 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
*/ */
#include <config.h> #include "config.h"
#include "rofi.h" #include "rofi.h"
#include "xrmoptions.h" #include "xrmoptions.h"
#include <glib.h> #include <glib.h>
#include <nkutils-bindings.h>
#include <string.h> #include <string.h>
#include "nkutils-bindings.h"
typedef struct { typedef struct {
guint id; guint id;
@ -373,7 +373,7 @@ static const gchar *mouse_default_bindings[] = {
[MOUSE_DCLICK_UP] = "!MouseDPrimary", [MOUSE_DCLICK_UP] = "!MouseDPrimary",
}; };
void abe_list_all_bindings(gboolean is_term ) { void abe_list_all_bindings(gboolean is_term) {
int length = 0; int length = 0;
for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) { for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) {
@ -384,9 +384,10 @@ void abe_list_all_bindings(gboolean is_term ) {
for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) { for (gsize i = 0; i < G_N_ELEMENTS(rofi_bindings); ++i) {
ActionBindingEntry *b = &rofi_bindings[i]; ActionBindingEntry *b = &rofi_bindings[i];
if (is_term) { if (is_term) {
printf("%s%*s%s - %s\n", color_bold,length, b->name, color_reset,b->binding); printf("%s%*s%s - %s\n", color_bold, length, b->name, color_reset,
b->binding);
} else { } else {
printf("%*s - %s\n", length, b->name, b->binding); printf("%*s - %s\n", length, b->name, b->binding);
} }
} }
} }
@ -440,22 +441,25 @@ gboolean parse_keys_abe(NkBindings *bindings) {
if (!nk_bindings_add_binding(bindings, b->scope, entry, if (!nk_bindings_add_binding(bindings, b->scope, entry,
binding_check_action, binding_trigger_action, binding_check_action, binding_trigger_action,
GUINT_TO_POINTER(b->id), NULL, &error)) { GUINT_TO_POINTER(b->id), NULL, &error)) {
if ( error->code == NK_BINDINGS_ERROR_ALREADY_REGISTERED && error->domain == NK_BINDINGS_ERROR){ if (error->code == NK_BINDINGS_ERROR_ALREADY_REGISTERED &&
char *str = g_markup_printf_escaped( error->domain == NK_BINDINGS_ERROR) {
"Failed to set binding <i>%s</i> for: <i>%s (%s)</i>:\n\t<span " char *str = g_markup_printf_escaped(
"size=\"smaller\" style=\"italic\">Binding `%s` is already bound.\n" "Failed to set binding <i>%s</i> for: <i>%s (%s)</i>:\n\t<span "
"\tExecute <b>rofi -list-keybindings</b> to get the current list of configured bindings.</span>\n", "size=\"smaller\" style=\"italic\">Binding `%s` is already "
b->binding, b->comment, b->name, entry); "bound.\n"
g_string_append(error_msg, str); "\tExecute <b>rofi -list-keybindings</b> to get the current list "
g_free(str); "of configured bindings.</span>\n",
} else { b->binding, b->comment, b->name, entry);
char *str = g_markup_printf_escaped( g_string_append(error_msg, str);
"Failed to set binding <i>%s</i> for: <i>%s (%s)</i>:\n\t<span " g_free(str);
"size=\"smaller\" style=\"italic\">%s</span>\n", } else {
b->binding, b->comment, b->name, error->message); char *str = g_markup_printf_escaped(
g_string_append(error_msg, str); "Failed to set binding <i>%s</i> for: <i>%s (%s)</i>:\n\t<span "
g_free(str); "size=\"smaller\" style=\"italic\">%s</span>\n",
} b->binding, b->comment, b->name, error->message);
g_string_append(error_msg, str);
g_free(str);
}
g_clear_error(&error); g_clear_error(&error);
} }
} }