static void on_media_player_key_pressed (TotemObject *totem, const gchar *key) { if (strcmp ("Play", key) == 0) totem_action_play_pause (totem); else if (strcmp ("Previous", key) == 0) totem_action_previous (totem); else if (strcmp ("Next", key) == 0) totem_action_next (totem); else if (strcmp ("Stop", key) == 0) totem_action_pause (totem); else if (strcmp ("FastForward", key) == 0) totem_action_remote (totem, TOTEM_REMOTE_COMMAND_SEEK_FORWARD, NULL); else if (strcmp ("Rewind", key) == 0) totem_action_remote (totem, TOTEM_REMOTE_COMMAND_SEEK_BACKWARD, NULL); else if (strcmp ("Repeat", key) == 0) { gboolean value; value = totem_action_remote_get_setting (totem, TOTEM_REMOTE_SETTING_REPEAT); totem_action_remote_set_setting (totem, TOTEM_REMOTE_SETTING_REPEAT, !value); } else if (strcmp ("Shuffle", key) == 0) { gboolean value; value = totem_action_remote_get_setting (totem, TOTEM_REMOTE_SETTING_SHUFFLE); totem_action_remote_set_setting (totem, TOTEM_REMOTE_SETTING_SHUFFLE, !value); } }
static gboolean totem_lirc_read_code (GIOChannel *source, GIOCondition condition, TotemLircPlugin *pi) { char *code; char *str = NULL, *url = NULL; int ok; TotemRemoteCommand cmd; if (condition & (G_IO_ERR | G_IO_HUP)) { /* LIRC connection broken. */ return FALSE; } /* this _could_ block, but it shouldn't */ lirc_nextcode (&code); if (code == NULL) { /* the code was incomplete or something */ return TRUE; } do { ok = lirc_code2char (pi->lirc_config, code, &str); if (ok != 0) { /* Couldn't convert lirc code to string. */ break; } if (str == NULL) { /* there was no command associated with the code */ break; } if (g_str_has_prefix (str, TOTEM_IR_SETTING) != FALSE) { TotemRemoteSetting setting; setting = totem_lirc_to_setting (str, &url); if (setting >= 0) { gboolean value; value = totem_action_remote_get_setting (pi->totem, setting); totem_action_remote_set_setting (pi->totem, setting, !value); } } else { cmd = totem_lirc_to_command (str, &url); totem_action_remote (pi->totem, cmd, url); } g_free (url); } while (TRUE); g_free (code); return TRUE; }