diff options
author | Gabor Karsay <gabor.karsay@gmx.at> | 2019-10-21 12:24:31 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2019-10-23 10:44:12 +0200 |
commit | f0599bf4b1f21d635e6d60582b8e7f009c7473da (patch) | |
tree | e366dabc15d04d0effc30063fea0c3a10a51d24e /src | |
parent | 03557731daa634ceb38d1e10588f10b5f3a4eec7 (diff) | |
download | totem-f0599bf4b1f21d635e6d60582b8e7f009c7473da.tar.gz |
variable-rate: Fix bracket keys and backspace not working in search entry
Let plugin handle key press events only in player mode and propagate them
in all other modes, e.g. to the search entry.
Closes: #212
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/variable-rate/totem-variable-rate-plugin.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/plugins/variable-rate/totem-variable-rate-plugin.c b/src/plugins/variable-rate/totem-variable-rate-plugin.c index 792c0cb69..c59a31078 100644 --- a/src/plugins/variable-rate/totem-variable-rate-plugin.c +++ b/src/plugins/variable-rate/totem-variable-rate-plugin.c @@ -48,8 +48,10 @@ typedef struct { TotemObject *totem; guint handler_id_key_press; + guint handler_id_main_page; GSimpleAction *action; GMenuItem *submenu_item; + gboolean player_page; } TotemVariableRatePluginPrivate; #define NUM_RATES 6 @@ -161,12 +163,24 @@ change_rate (TotemVariableRatePlugin *pi, g_action_change_state (G_ACTION (priv->action), state); } +static void +on_totem_main_page_notify (GObject *object, GParamSpec *spec, TotemVariableRatePlugin *plugin) +{ + TotemVariableRatePlugin *pi = TOTEM_VARIABLE_RATE_PLUGIN (plugin); + char *main_page; + + g_object_get (pi->priv->totem, "main-page", &main_page, NULL); + pi->priv->player_page = (g_strcmp0 (main_page, "player") == 0); + g_free (main_page); +} + static gboolean on_window_key_press_event (GtkWidget *window, GdkEventKey *event, TotemVariableRatePlugin *plugin) { TotemVariableRatePlugin *pi = TOTEM_VARIABLE_RATE_PLUGIN (plugin); - if (event->state == 0 || + if (!pi->priv->player_page || + event->state == 0 || event->state & (GDK_CONTROL_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK)) { return FALSE; } @@ -200,6 +214,12 @@ impl_activate (PeasActivatable *plugin) priv->totem = g_object_get_data (G_OBJECT (plugin), "object"); + /* Cache totem's main page */ + priv->handler_id_main_page = g_signal_connect (G_OBJECT(priv->totem), + "notify::main-page", + G_CALLBACK (on_totem_main_page_notify), + pi); + /* Key press handler */ window = totem_object_get_main_window (priv->totem); priv->handler_id_key_press = g_signal_connect (G_OBJECT(window), @@ -245,6 +265,12 @@ impl_deactivate (PeasActivatable *plugin) g_object_unref (window); } + if (priv->handler_id_main_page != 0) { + g_signal_handler_disconnect (G_OBJECT(priv->totem), + priv->handler_id_main_page); + priv->handler_id_main_page = 0; + } + /* Remove the menu */ totem_object_empty_menu_section (priv->totem, "variable-rate-placeholder"); |