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

bindings: Use a wrapper around rofi_view_trigger_action

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2017-05-30 14:14:51 +02:00
parent 135d845790
commit 4891bcd7eb
No known key found for this signature in database
GPG key ID: AC203F96E2C34BB7
4 changed files with 15 additions and 10 deletions

View file

@ -139,11 +139,12 @@ void rofi_view_restart ( RofiViewState *state );
/**
* @param state The handle to the view
* @param action The keyboard action
* @param scope The scope of the action
* @param action The action
*
* @returns TRUE if action was handled.
*/
gboolean rofi_view_trigger_action ( guint scope, gpointer user_data );
gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action );
/**
* @param state The handle to the view

View file

@ -140,6 +140,11 @@ void setup_abe ( void )
}
}
static gboolean binding_trigger_action ( guint scope, gpointer user_data )
{
return rofi_view_trigger_action ( rofi_view_get_active (), scope, GPOINTER_TO_UINT ( user_data ) );
}
gboolean parse_keys_abe ( NkBindings *bindings )
{
GError *error = NULL;
@ -152,7 +157,7 @@ gboolean parse_keys_abe ( NkBindings *bindings )
// Iter over bindings.
const char *const sep = ",";
for ( char *entry = strtok_r ( keystr, sep, &sp ); entry != NULL; entry = strtok_r ( NULL, sep, &sp ) ) {
if ( !nk_bindings_add_binding ( bindings, b->scope, entry, rofi_view_trigger_action, GUINT_TO_POINTER ( b->id ), NULL, &error ) ) {
if ( !nk_bindings_add_binding ( bindings, b->scope, entry, binding_trigger_action, GUINT_TO_POINTER ( b->id ), NULL, &error ) ) {
g_string_append_c ( g_string_append ( error_msg, error->message ), '\n' );
g_clear_error ( &error );
}
@ -168,7 +173,7 @@ gboolean parse_keys_abe ( NkBindings *bindings )
for ( gsize i = SCOPE_MIN_FIXED; i <= SCOPE_MAX_FIXED; ++i ) {
for ( gsize j = 1; j < G_N_ELEMENTS ( mouse_default_bindings ); ++j ) {
nk_bindings_add_binding ( bindings, i, mouse_default_bindings[j], rofi_view_trigger_action, GSIZE_TO_POINTER ( j ), NULL, NULL );
nk_bindings_add_binding ( bindings, i, mouse_default_bindings[j], binding_trigger_action, GSIZE_TO_POINTER ( j ), NULL, NULL );
}
}

View file

@ -1343,13 +1343,12 @@ static void rofi_view_trigger_global_action ( KeyBindingAction action )
}
}
gboolean rofi_view_trigger_action ( guint scope, gpointer user_data )
gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
{
RofiViewState *state = rofi_view_get_active ();
switch ( (BindingsScope) scope )
switch ( scope )
{
case SCOPE_GLOBAL:
rofi_view_trigger_global_action ( GPOINTER_TO_UINT ( user_data ) );
rofi_view_trigger_global_action ( action );
return TRUE;
case SCOPE_MOUSE_LISTVIEW:
case SCOPE_MOUSE_LISTVIEW_ELEMENT:
@ -1363,7 +1362,7 @@ gboolean rofi_view_trigger_action ( guint scope, gpointer user_data )
return FALSE;
}
widget_xy_to_relative ( target, &x, &y );
switch ( widget_trigger_action ( target, GPOINTER_TO_UINT ( user_data ), x, y ) )
switch ( widget_trigger_action ( target, action, x, y ) )
{
case WIDGET_TRIGGER_ACTION_RESULT_IGNORED:
return FALSE;

View file

@ -69,7 +69,7 @@ RofiViewState * rofi_view_get_active ( void )
{
return NULL;
}
gboolean rofi_view_trigger_action ( G_GNUC_UNUSED guint scope, G_GNUC_UNUSED gpointer user_data )
gboolean rofi_view_trigger_action ( G_GNUC_UNUSED RofiViewState *state, G_GNUC_UNUSED BindingsScope scope, G_GNUC_UNUSED guint action )
{
return FALSE;
}